Is there a way to perform a key-press rather than a key down? By checking if a key is down, then swapping a state (in my instance switching on and off lighting), it constantly switches state and it’s random which state I get because I’m not fast enough to get my finger off the button before it has ‘looped’ again.
There has to be a better way to do this?
Sure, implement something like the following:
boolean F12_DOWN = false ;
if(Keyboard.isKeyDown(Keyboard.KEY_F12))
{
if(F12_DOWN == false)
{
F12_DOWN = true ;
swapLighting() ;
}
}
else
F12_DOWN = false ;
Also the new keyboard buffer will do it I believe:
Keyboard.enableBuffer();
...
Keyboard.read();
while (Keyboard.next()) {
if (Keyboard.state) {
int keyCode = Keyboard.key;
...
}
}
This gives you a series of discrete up and down events as they occur instead of a simple polling state.
Cas 
[quote]Sure, implement something like the following:
boolean F12_DOWN = false ;
if(Keyboard.isKeyDown(Keyboard.KEY_F12))
{
if(F12_DOWN == false)
{
F12_DOWN = true ;
swapLighting() ;
}
}
else
F12_DOWN = false ;
[/quote]
This is kind of what I had. The thing is, if your game does 200 FPS (…9700 Pro :)) and you push the button for 1/4 second, the F12_DOWN variable has switched on and off about 50 times. It is not guaranteed to be the opposite of the state it was when you pushed the key.
Cas… how does the buffer state help? Can I detect in the buffer the key being pushed, followed by it being released?
If you look a bit more closely at Charlie’s code you’ll see that it does nothing on subsequent frames until the key is released, although he hasn’t made it clear that F12_down is an instance variable somewhere in a class, not a local variable.
This is more or less what’s going on in the directinput driver behind the Keyboard buffer anyway. You get single key down / key up events. Key repeat does not occur.
Cas 
Er, yeah. Sorry, I thought about mentioning that explicitly, but for some reason decided not to! ;D
Interesting, I hadn’t noticed the keyboard buffer system in LWJGL yet - I’ll be sure to give it a try.