i'm trying to map KeyState to awt.KeyEvent with the following code piece:
int modifiers = 0;
if (Keyboard.isKeyDown(Keyboard.KEY_LCONTROL) || Keyboard.isKeyDown(Keyboard.KEY_RCONTROL))
modifiers |= KeyEvent.CTRL_DOWN_MASK;
if (Keyboard.isKeyDown(Keyboard.KEY_LSHIFT) || Keyboard.isKeyDown(Keyboard.KEY_RSHIFT))
modifiers |= KeyEvent.SHIFT_DOWN_MASK;
final KeyEvent keyEvent;
if (state.getState()) // pressed
keyEvent = new KeyEvent(EVENT_SOURCE, KeyEvent.KEY_PRESSED, 0, modifiers, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED);
else keyEvent = new KeyEvent(EVENT_SOURCE, KeyEvent.KEY_RELEASED, 0, modifiers, state.getKeyCode(), KeyEvent.CHAR_UNDEFINED);
but unfortunately Keyboard.isKeyDown(left-right control) never returns true. pressing/releasing control key never generates an event either. any ideas why this may happen ?
this is a fedora 4 linux laptop, with only left control key. awt itself properly generates control key events
btw, it may be handy to include modifiers in KeyState class.
r a f t