accomplishing key repeat

I’ve got Keyboard (LWJGL 0.7) going well, but how do I get it to recognize key repeat? Pressing and holding a button only generates one event (which generally is good), but for when the user is typing stuff I’d like them to have key repeat.

my Keyboard initialization is just


                  Keyboard.create();
                  Keyboard.enableBuffer();
                  Keyboard.enableTranslation();

(which, btw, what does translation really do?)

and I read it with (once per frame)


            Keyboard.read();
            // buffer is my own data structure
            buffer.resetCount();
            
            while(Keyboard.next()) {
                  if(Keyboard.state) {
                        buffer.add(Keyboard.key, Keyboard.character);      
                  }
            }

I could maintain state of each key with a boolean and as long as the key is down stick events into my buffer at a constant rate, which wouldn’t be too bad. But maybe there’s a common, easier way to go about it?

The code above makes it so pressing and holding a key only generates one event, so say pressing and holding backspace will erase only one character.

I’ve looked around here and at the lwjgl forum without much luck.

That’s coz we don’t actually support key repeat yet. You’ll have to do a hack for now.

Cas :slight_smile:

Oh I knew that. But I figured that since it’s not directly supported maybe those before me have already done some hacks I could cheat from :slight_smile:

Further playing with it it’s actually not too difficult, much like the classic boolean for key’s being down in the AWT event system in reverse. Er, if that makes any sense…