public final class Keyboard extends java.lang.Object implements java.awt.KeyEventDispatcher, IKeyboard, IUpdateable
IKeyboard.KeyPressedListener, IKeyboard.KeyReleasedListener, IKeyboard.KeyTypedListener| Modifier and Type | Method and Description |
|---|---|
void |
addKeyListener(java.awt.event.KeyListener listener)
Register for key events.
|
void |
clearExplicitListeners()
Removes all registered event consumers from the Keyboard instance.
|
void |
consumeAlt(boolean consume)
Specifies whether the engine should consume key events with the ALT modifier.
|
boolean |
dispatchKeyEvent(java.awt.event.KeyEvent e) |
boolean |
isPressed(int keyCode)
Checks whether the key with the specified
keyCode is currently being pressed. |
void |
onKeyPressed(IKeyboard.KeyPressedListener listener)
Adds the specified key pressed listener to receive events when any key has been pressed.
|
void |
onKeyPressed(int keyCode,
IKeyboard.KeyPressedListener listener)
Adds the specified key pressed listener to receive events when the key with the defined
keyCode has been pressed. |
void |
onKeyReleased(IKeyboard.KeyReleasedListener listener)
Adds the specified key released listener to receive events when any key has been released.
|
void |
onKeyReleased(int keyCode,
IKeyboard.KeyReleasedListener listener)
Adds the specified key released listener to receive events when the key with the defined
keyCode has been released. |
void |
onKeyTyped(IKeyboard.KeyTypedListener listener)
Adds the specified key typed listener to receive events when any key has been typed.
|
void |
onKeyTyped(int keyCode,
IKeyboard.KeyTypedListener listener)
Adds the specified key typed listener to receive events when the key with the defined
keyCode has been typed. |
void |
removeKeyListener(java.awt.event.KeyListener listener)
Unregister the specified listener from key events.
|
void |
removeKeyPressedListener(IKeyboard.KeyPressedListener listener)
Unregister the specified listener from key pressed events.
|
void |
removeKeyPressedListener(int keyCode,
IKeyboard.KeyPressedListener listener)
Unregister the specified listener from key pressed events.
|
void |
removeKeyReleasedListener(IKeyboard.KeyReleasedListener listener)
Unregister the specified listener from key released events.
|
void |
removeKeyReleasedListener(int keyCode,
IKeyboard.KeyReleasedListener listener)
Unregister the specified listener from key released events.
|
void |
removeKeyTypedListener(IKeyboard.KeyTypedListener listener)
Unregister the specified listener from key typed events.
|
void |
removeKeyTypedListener(int keyCode,
IKeyboard.KeyTypedListener listener)
Unregister the specified listener from key typed events.
|
void |
update()
This method is called by the game loop on all objects that are attached to the loop.
|
public void consumeAlt(boolean consume)
IKeyboardThis is useful to prevent unintended behavior of the default key processing.
consumeAlt in interface IKeyboardconsume - True if the events with the ALT modifier should be consumed.InputEvent.consume(),
InputEvent.isAltDown()public boolean dispatchKeyEvent(java.awt.event.KeyEvent e)
dispatchKeyEvent in interface java.awt.KeyEventDispatcherpublic boolean isPressed(int keyCode)
IKeyboardkeyCode is currently being pressed.isPressed in interface IKeyboardkeyCode - The keyCode to check for.IKeyboard.onKeyPressed(KeyPressedListener),
IKeyboard.onKeyPressed(int, KeyPressedListener)public void onKeyPressed(int keyCode,
IKeyboard.KeyPressedListener listener)
IKeyboardkeyCode has been pressed.onKeyPressed in interface IKeyboardkeyCode - The keyCode to capture the key pressed event for.listener - The listener to add.KeyListener.keyPressed(KeyEvent),
KeyEvent.KEY_PRESSEDpublic void removeKeyPressedListener(int keyCode,
IKeyboard.KeyPressedListener listener)
IKeyboardremoveKeyPressedListener in interface IKeyboardkeyCode - The keyCode for which to remove the listener.listener - The listener to remove.public void onKeyReleased(int keyCode,
IKeyboard.KeyReleasedListener listener)
IKeyboardkeyCode has been released.onKeyReleased in interface IKeyboardkeyCode - The keyCode to capture the key released event for.listener - The listener to add.KeyListener.keyReleased(KeyEvent),
KeyEvent.KEY_RELEASEDpublic void removeKeyReleasedListener(int keyCode,
IKeyboard.KeyReleasedListener listener)
IKeyboardremoveKeyReleasedListener in interface IKeyboardkeyCode - The keyCode for which to remove the listener.listener - The listener to remove.public void onKeyTyped(int keyCode,
IKeyboard.KeyTypedListener listener)
IKeyboardkeyCode has been typed.onKeyTyped in interface IKeyboardkeyCode - The keyCode to capture the key typed event for.listener - The listener to add.KeyListener.keyTyped(KeyEvent),
KeyEvent.KEY_TYPEDpublic void removeKeyTypedListener(int keyCode,
IKeyboard.KeyTypedListener listener)
IKeyboardremoveKeyTypedListener in interface IKeyboardkeyCode - The keyCode for which to remove the listener.listener - The listener to remove.public void onKeyPressed(IKeyboard.KeyPressedListener listener)
IKeyboardonKeyPressed in interface IKeyboardlistener - The listener to add.KeyListener.keyPressed(KeyEvent),
KeyEvent.KEY_PRESSEDpublic void removeKeyPressedListener(IKeyboard.KeyPressedListener listener)
IKeyboardremoveKeyPressedListener in interface IKeyboardlistener - The listener to remove.public void onKeyReleased(IKeyboard.KeyReleasedListener listener)
IKeyboardonKeyReleased in interface IKeyboardlistener - The listener to add.KeyListener.keyReleased(KeyEvent),
KeyEvent.KEY_RELEASEDpublic void removeKeyReleasedListener(IKeyboard.KeyReleasedListener listener)
IKeyboardremoveKeyReleasedListener in interface IKeyboardlistener - The listener to remove.public void onKeyTyped(IKeyboard.KeyTypedListener listener)
IKeyboardonKeyTyped in interface IKeyboardlistener - The listener to add.KeyListener.keyTyped(KeyEvent),
KeyEvent.KEY_TYPEDpublic void removeKeyTypedListener(IKeyboard.KeyTypedListener listener)
IKeyboardremoveKeyTypedListener in interface IKeyboardlistener - The listener to remove.public void clearExplicitListeners()
IKeyboardKeyListener instances.clearExplicitListeners in interface IKeyboardIKeyboard.onKeyPressed(KeyPressedListener),
IKeyboard.onKeyPressed(int, KeyPressedListener),
IKeyboard.onKeyReleased(KeyReleasedListener),
IKeyboard.onKeyReleased(int, KeyReleasedListener),
IKeyboard.onKeyTyped(KeyTypedListener),
IKeyboard.onKeyTyped(int, KeyTypedListener)public void addKeyListener(java.awt.event.KeyListener listener)
IKeyboardaddKeyListener in interface IKeyboardlistener - The listener to add.public void removeKeyListener(java.awt.event.KeyListener listener)
IKeyboardremoveKeyListener in interface IKeyboardlistener - The listener to remove.public void update()
IUpdateableClientConfiguration.update in interface IUpdateableClientConfiguration.setMaxFps(int)