Keyboard input for a game in Java
Posted
by hmp
on Stack Overflow
See other posts from Stack Overflow
or by hmp
Published on 2010-04-23T21:56:04Z
Indexed on
2010/04/23
22:23 UTC
Read the original article
Hit count: 343
I'm writing a game in Java, right now it's Swing + JOGL - a JFrame with a GLCanvas.
I handle input using keyPressed
etc. events (jframe.addKeyListener(...)
) and it doesn't seem to work properly:
- when I have 3+ keys down at the same time, they don't register properly
- after the window loses, then regains focus, input stops working completely...
What am I doing wrong?
Is there a better way of handling keyboard input in Java?
(I'd rather not switch to another library, like LWJGL... unless I have no choice).
© Stack Overflow or respective owner