benfry / processing4

Processing 4.x releases for Java 17
https://processing.org
Other
1.31k stars 236 forks source link

with P2D renderer `key` variable doesnt update when pressing CTRL and another key #795

Open grimtin10 opened 8 months ago

grimtin10 commented 8 months ago

Description

When using the P2D renderer the key variable doesn't update when pressing control and then another key.

Expected Behavior

Pressing control and then another key should set the key variable to CODED (65535) and then whatever other key you pressed.

Current Behavior

Pressing control and then another key doesn't update the key variable and it ends up containing CODED for both key presses and any subsequent key presses.

Steps to Reproduce

  1. Set renderer to P2D
  2. Create a keyPressed function that prints out the key variable
  3. Press control and then another key

Your Environment

Possible Causes / Solutions

OpenGL renderer isn't updating key variable when it should be.

krishna2803 commented 6 months ago

Are you pressing both the keys CTRL and (any other key) simultaneously? As in CTRL+<key>? Or CTRL then <key> ? Also in-case this helps, key should contain CODED and if you want to get the value of the key, use keyCode instead of key.

// using P2D
void keyPressed() {
    if (key == CODED) {
        println((char)keyCode);
    }
}