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 ClassesModifier and TypeInterfaceDescriptionstatic interfaceThis listener interface receives pressed events for the keyboard.static interfaceThis listener interface receives released events for the keyboard.static interfaceThis listener interface receives typed events for the keyboard. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddKeyListener(KeyListener listener) Register for key events.voidRemoves all registered event consumers from the Keyboard instance.voidconsumeAlt(boolean consume) Specifies whether the engine should consume key events with the ALT modifier.booleanisPressed(int keyCode) Checks whether the key with the specifiedkeyCodeis currently being pressed.voidonKeyPressed(int keyCode, IKeyboard.KeyPressedListener listener) Adds the specified key pressed listener to receive events when the key with the definedkeyCodehas been pressed.voidonKeyPressed(IKeyboard.KeyPressedListener listener) Adds the specified key pressed listener to receive events when any key has been pressed.voidonKeyReleased(int keyCode, IKeyboard.KeyReleasedListener listener) Adds the specified key released listener to receive events when the key with the definedkeyCodehas been released.voidonKeyReleased(IKeyboard.KeyReleasedListener listener) Adds the specified key released listener to receive events when any key has been released.voidonKeyTyped(int keyCode, IKeyboard.KeyTypedListener listener) Adds the specified key typed listener to receive events when the key with the definedkeyCodehas been typed.voidonKeyTyped(IKeyboard.KeyTypedListener listener) Adds the specified key typed listener to receive events when any key has been typed.voidremoveKeyListener(KeyListener listener) Unregister the specified listener from key events.voidremoveKeyPressedListener(int keyCode, IKeyboard.KeyPressedListener listener) Unregister the specified listener from key pressed events.voidUnregister the specified listener from key pressed events.voidremoveKeyReleasedListener(int keyCode, IKeyboard.KeyReleasedListener listener) Unregister the specified listener from key released events.voidUnregister the specified listener from key released events.voidremoveKeyTypedListener(int keyCode, IKeyboard.KeyTypedListener listener) Unregister the specified listener from key typed events.voidUnregister the specified listener from key typed events.booleanwasReleased(int keyCode) Checks whether the key with the specifiedkeyCodewas 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:
-
isPressed
boolean isPressed(int keyCode) Checks whether the key with the specifiedkeyCodeis currently being pressed.- Parameters:
keyCode- The keyCode to check for.- Returns:
- True if the key with the specified code is currently pressed.
- See Also:
-
wasReleased
boolean wasReleased(int keyCode) Checks whether the key with the specifiedkeyCodewas recently released.- Parameters:
keyCode- The keyCode to check for.- Returns:
- True if the key with the specified code was recently released.
- See Also:
-
onKeyPressed
Adds the specified key pressed listener to receive events when the key with the definedkeyCodehas been pressed.- Parameters:
keyCode- The keyCode to capture the key pressed event for.listener- The listener to add.- See Also:
-
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 definedkeyCodehas been released.- Parameters:
keyCode- The keyCode to capture the key released event for.listener- The listener to add.- See Also:
-
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 definedkeyCodehas been typed.- Parameters:
keyCode- The keyCode to capture the key typed event for.listener- The listener to add.- See Also:
-
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:
-
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:
-
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:
-
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 registeredKeyListenerinstances.- See Also:
-
addKeyListener
Register for key events.- Parameters:
listener- The listener to add.
-
removeKeyListener
Unregister the specified listener from key events.- Parameters:
listener- The listener to remove.
-