Package de.gurkenlabs.litiengine.input
Interface IKeyboard
- All Known Implementing Classes:
Keyboard
public interface IKeyboard
The
IKeyboard
interface is the engine's API for receiving keyboard input events.Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
IKeyboard.KeyPressedListener
This listener interface receives pressed events for the keyboard.static interface
IKeyboard.KeyReleasedListener
This listener interface receives released events for the keyboard.static interface
IKeyboard.KeyTypedListener
This listener interface receives typed events for the keyboard.Method Summary
Modifier and Type Method 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
isPressed(int keyCode)
Checks whether the key with the specifiedkeyCode
is currently being pressed.void
onKeyPressed(int keyCode, IKeyboard.KeyPressedListener listener)
Adds the specified key pressed listener to receive events when the key with the definedkeyCode
has been pressed.void
onKeyPressed(IKeyboard.KeyPressedListener listener)
Adds the specified key pressed listener to receive events when any key has been pressed.void
onKeyReleased(int keyCode, IKeyboard.KeyReleasedListener listener)
Adds the specified key released listener to receive events when the key with the definedkeyCode
has been released.void
onKeyReleased(IKeyboard.KeyReleasedListener listener)
Adds the specified key released listener to receive events when any key has been released.void
onKeyTyped(int keyCode, IKeyboard.KeyTypedListener listener)
Adds the specified key typed listener to receive events when the key with the definedkeyCode
has been typed.void
onKeyTyped(IKeyboard.KeyTypedListener listener)
Adds the specified key typed listener to receive events when any key has been typed.void
removeKeyListener(java.awt.event.KeyListener listener)
Unregister the specified listener from key events.void
removeKeyPressedListener(int keyCode, IKeyboard.KeyPressedListener listener)
Unregister the specified listener from key pressed events.void
removeKeyPressedListener(IKeyboard.KeyPressedListener listener)
Unregister the specified listener from key pressed events.void
removeKeyReleasedListener(int keyCode, IKeyboard.KeyReleasedListener listener)
Unregister the specified listener from key released events.void
removeKeyReleasedListener(IKeyboard.KeyReleasedListener listener)
Unregister the specified listener from key released events.void
removeKeyTypedListener(int keyCode, IKeyboard.KeyTypedListener listener)
Unregister the specified listener from key typed events.void
removeKeyTypedListener(IKeyboard.KeyTypedListener listener)
Unregister the specified listener from key typed events.boolean
wasReleased(int keyCode)
Checks whether the key with the specifiedkeyCode
was recently released.
Method Details
consumeAlt
void consumeAlt(boolean consume)Specifies whether the engine should consume key events with the ALT modifier.This is useful to prevent unintended behavior of the default key processing.
- Parameters:
consume
- True if the events with the ALT modifier should be consumed.- See Also:
InputEvent.consume()
,InputEvent.isAltDown()
isPressed
boolean isPressed(int keyCode)Checks whether the key with the specifiedkeyCode
is currently being pressed.- Parameters:
keyCode
- The keyCode to check for.- Returns:
- True if the key with the specified code is currently pressed.
- See Also:
onKeyPressed(KeyPressedListener)
,onKeyPressed(int, KeyPressedListener)
wasReleased
boolean wasReleased(int keyCode)Checks whether the key with the specifiedkeyCode
was recently released.- Parameters:
keyCode
- The keyCode to check for.- Returns:
- True if the key with the specified code was recently released.
- See Also:
onKeyReleased(KeyReleasedListener)
,onKeyReleased(int, KeyReleasedListener)
onKeyPressed
Adds the specified key pressed listener to receive events when the key with the definedkeyCode
has been pressed.- Parameters:
keyCode
- The keyCode to capture the key pressed event for.listener
- The listener to add.- See Also:
KeyListener.keyPressed(KeyEvent)
,KeyEvent.KEY_PRESSED
removeKeyPressedListener
Unregister the specified listener from key pressed events.- Parameters:
keyCode
- The keyCode for which to remove the listener.listener
- The listener to remove.
onKeyReleased
Adds the specified key released listener to receive events when the key with the definedkeyCode
has been released.- Parameters:
keyCode
- The keyCode to capture the key released event for.listener
- The listener to add.- See Also:
KeyListener.keyReleased(KeyEvent)
,KeyEvent.KEY_RELEASED
removeKeyReleasedListener
Unregister the specified listener from key released events.- Parameters:
keyCode
- The keyCode for which to remove the listener.listener
- The listener to remove.
onKeyTyped
Adds the specified key typed listener to receive events when the key with the definedkeyCode
has been typed.- Parameters:
keyCode
- The keyCode to capture the key typed event for.listener
- The listener to add.- See Also:
KeyListener.keyTyped(KeyEvent)
,KeyEvent.KEY_TYPED
removeKeyTypedListener
Unregister the specified listener from key typed events.- Parameters:
keyCode
- The keyCode for which to remove the listener.listener
- The listener to remove.
onKeyPressed
Adds the specified key pressed listener to receive events when any key has been pressed.- Parameters:
listener
- The listener to add.- See Also:
KeyListener.keyPressed(KeyEvent)
,KeyEvent.KEY_PRESSED
removeKeyPressedListener
Unregister the specified listener from key pressed events.- Parameters:
listener
- The listener to remove.
onKeyReleased
Adds the specified key released listener to receive events when any key has been released.- Parameters:
listener
- The listener to add.- See Also:
KeyListener.keyReleased(KeyEvent)
,KeyEvent.KEY_RELEASED
removeKeyReleasedListener
Unregister the specified listener from key released events.- Parameters:
listener
- The listener to remove.
onKeyTyped
Adds the specified key typed listener to receive events when any key has been typed.- Parameters:
listener
- The listener to add.- See Also:
KeyListener.keyTyped(KeyEvent)
,KeyEvent.KEY_TYPED
removeKeyTypedListener
Unregister the specified listener from key typed events.- Parameters:
listener
- The listener to remove.
clearExplicitListeners
void clearExplicitListeners()Removes all registered event consumers from the Keyboard instance. This does not affect registeredKeyListener
instances.addKeyListener
void addKeyListener(java.awt.event.KeyListener listener)Register for key events.- Parameters:
listener
- The listener to add.
removeKeyListener
void removeKeyListener(java.awt.event.KeyListener listener)Unregister the specified listener from key events.- Parameters:
listener
- The listener to remove.