Skip to main content
gamedev.net
🔒 Locked

[java] Avoiding repetative key events

Started by csDraco_ Jun 12, 2002 at 9:54 PM 1 replies 500+ views
Original Post
csDraco_
csDraco_
Hello there! I'm writing a 3D modeler/viwer in Java, and came up with a problem while in the viewing mode. I'm using the KeyListener interface to handle keyboard events for walking around / viewing models, which is when holding down a key for over a second I get repetative key up and down events, and I don't wont any up events from the very same key, untill I let it go. What can I do to change those repetative events into the single up event followed by a single down event ... or a representation of that? Thanks in advance. [edited by - csDraco_ on June 12, 2002 10:57:15 PM]
csDraco_
csDraco_
Thanks for responding.
I''m using the "flag" aproach, and it works quite well, I''m just wondering if there is another way, because it seams not to be 100% acurate, since the pressed key (after some time .. about 1sec. in my case) begins to generate an up event followed by a down event ... and so on, untill I let go of that key (where the final up event is registered).
The "flag" aproach works well bacause (I''m to too sure about this ... but I think that) the period of time from the down event to the up event is much longer than the period of time from the up event to the down event. Which causes the flag to be up (key pressed down) most of the time, but not all of the time, during which the key is pressed down.

Is there a way of improving the accuracy of the "flag" aproch, or is there a different way of going about this?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.