Skip to content

SHIFT and PAGE_UP keys use the same keyCode in P2D and P3D #702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
processing-bot opened this issue Apr 15, 2023 · 3 comments · May be fixed by #1033
Open

SHIFT and PAGE_UP keys use the same keyCode in P2D and P3D #702

processing-bot opened this issue Apr 15, 2023 · 3 comments · May be fixed by #1033
Labels
help wanted Extra attention is needed opengl

Comments

@processing-bot
Copy link
Collaborator

Created by: slu4coder

Hi guys,

thanks for your excellent work on Processing 4. Sorry to report this annoying issue making it essentially impossible to detect the difference between SHIFT and PAGE_UP when using the P2D renderer. Problem: Both use keyCode = 16 :-(

This is not a problem under the DEFAULT renderer. It uses keyCodes 33-35 for HOME/END/PG_UP/PG_DN and 16 for SHIFT.
P2D however uses keyCodes 2, 3, 16(?) and 11 for the above keys and again 16 for SHIFT.

Btw, I am typing on a German keyboard but for the keys involved that shouldn't make any difference, I guess.

Good luck! slu4.

void setup() { size(200, 200, P2D); }
void draw() {}
void keyPressed() { println(key, int(key), key==CODED, keyCode); }

@processing-bot
Copy link
Collaborator Author

Created by: Chirimen-Jako

I was also trying to submit the exact same issue, but I'm adding it here since I found this report. I am using the P3D renderer and a Japanese keyboard. Like slu4coder, I cannot distinguish between the [Shift] key and the [Page Up] key because they both return the same keyCode 16.

Additionally, I would like to ask if this issue is dependent on the hardware type of the keyboard.

// Processing 4.2 on Windows 10 22H2 build 19045.3086
void setup(){
  size(320, 240, P3D);
  background(255);
}
void keyPressed(){
  // [Shift] returns '16 0x10'
  // [Page Up] returns '16 0x10'
  int kc = keyCode;
  println(kc + " 0x" + hex(kc, 2));
}
void draw(){}

@processing-bot
Copy link
Collaborator Author

Created by: Chirimen-Jako

I found a workaround.

// Processing 4.2 on Windows 10 22H2 build 19045.3086
void setup(){ size(320, 240, P3D); }
void draw(){}
void keyPressed(KeyEvent e){

  // Default renderer
  //java.awt.event.KeyEvent nativeEvent = (java.awt.event.KeyEvent)e.getNative();

  // P2D/P3D renderer
  com.jogamp.newt.event.KeyEvent nativeEvent = (com.jogamp.newt.event.KeyEvent)e.getNative();

  int kcd = keyCode; // default
  int kcn = nativeEvent.getKeyCode(); // native

  // renderer:default
  // keyCode   :  default   native         
  // [Shift]   :  16 0x10 / 16 0x10
  // [Page Up] :  33 0x21 / 33 0x21

  // renderer:P2D/P3D
  // keyCode   :  default   native         
  // [Shift]   :  16 0x10 / 15 0x0F
  // [Page Up] :  16 0x10 / 16 0x10

  println(kcd, "0x" + hex(kcd, 2), "/", kcn, "0x" + hex(kcn, 2));
}

@processing-bot
Copy link
Collaborator Author

Created by: benfry

Ok, these should be getting mapped properly to the same values as in the Java2D renderer.

@Rishab87 Rishab87 linked a pull request Apr 13, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed opengl
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant