KeyListener - keyPressed delay
-
Hey guys! Just a quick question... So I've added a
KeyListener
to myJPanel
for a game I'm making, and everything is working out fine, except for one thing: When I hold down a key,keyPressed
is called once, followed by a delay, followed by several consecutive calls of thekeyPressed
method. I understand that this has to do with the way key events are processed and that you can adjust this delay within the control panel, but is there any way to remove this delay completely? I'm thinking what I'm going to end up doing is creating aboolean keyDown
variable which is set to true onkeyPressed
and to false onkeyReleased
. Any other ideas? :) -
Hey guys! Just a quick question... So I've added a
KeyListener
to myJPanel
for a game I'm making, and everything is working out fine, except for one thing: When I hold down a key,keyPressed
is called once, followed by a delay, followed by several consecutive calls of thekeyPressed
method. I understand that this has to do with the way key events are processed and that you can adjust this delay within the control panel, but is there any way to remove this delay completely? I'm thinking what I'm going to end up doing is creating aboolean keyDown
variable which is set to true onkeyPressed
and to false onkeyReleased
. Any other ideas? :)