Login  Register

Re: key input Keylistener doesn't work for JOGL

Posted by jmaasing on Nov 08, 2017; 1:37pm
URL: https://forum.jogamp.org/key-input-Keylistener-doesn-t-work-for-JOGL-tp4038300p4038303.html

tragic_xxx wrote
gouessej wrote
If the GLCanvas receives the key events, the key listener will have to be added to it instead of the JFrame, it's a basic Swing problem, it's not a JOGL problem.
How do I add the KeyListener to JFrame correctly (in this context)?
Swing works that way, one component will have the keyboard focus and only that component will get key events. So _IF_ the canvas has keyboard focus the listener must be added to the canvas.

https://docs.oracle.com/javase/tutorial/uiswing/events/keylistener.html