Class Keyboard
java.lang.Object
de.gurkenlabs.litiengine.input.Keyboard
- All Implemented Interfaces:
IKeyboard,IUpdateable,KeyEventDispatcher
-
Nested Class Summary
Nested classes/interfaces inherited from interface de.gurkenlabs.litiengine.input.IKeyboard
IKeyboard.KeyPressedListener, IKeyboard.KeyReleasedListener, IKeyboard.KeyTypedListener -
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.booleanbooleanisPressed(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.voidupdate()This method is called by the game loop on all objects that are attached to the loop.booleanwasReleased(int keyCode) Checks whether the key with the specifiedkeyCodewas recently released.
-
Method Details
-
consumeAlt
public void consumeAlt(boolean consume) Description copied from interface:IKeyboardSpecifies whether the engine should consume key events with the ALT modifier.This is useful to prevent unintended behavior of the default key processing.
- Specified by:
consumeAltin interfaceIKeyboard- Parameters:
consume- True if the events with the ALT modifier should be consumed.- See Also:
-
dispatchKeyEvent
- Specified by:
dispatchKeyEventin interfaceKeyEventDispatcher
-
isPressed
public boolean isPressed(int keyCode) Description copied from interface:IKeyboardChecks whether the key with the specifiedkeyCodeis currently being pressed. -
wasReleased
public boolean wasReleased(int keyCode) Description copied from interface:IKeyboardChecks whether the key with the specifiedkeyCodewas recently released.- Specified by:
wasReleasedin interfaceIKeyboard- Parameters:
keyCode- The keyCode to check for.- Returns:
- True if the key with the specified code was recently released.
- See Also:
-
onKeyPressed
Description copied from interface:IKeyboardAdds the specified key pressed listener to receive events when the key with the definedkeyCodehas been pressed.- Specified by:
onKeyPressedin interfaceIKeyboard- Parameters:
keyCode- The keyCode to capture the key pressed event for.listener- The listener to add.- See Also:
-
removeKeyPressedListener
Description copied from interface:IKeyboardUnregister the specified listener from key pressed events.- Specified by:
removeKeyPressedListenerin interfaceIKeyboard- Parameters:
keyCode- The keyCode for which to remove the listener.listener- The listener to remove.
-
onKeyReleased
Description copied from interface:IKeyboardAdds the specified key released listener to receive events when the key with the definedkeyCodehas been released.- Specified by:
onKeyReleasedin interfaceIKeyboard- Parameters:
keyCode- The keyCode to capture the key released event for.listener- The listener to add.- See Also:
-
removeKeyReleasedListener
Description copied from interface:IKeyboardUnregister the specified listener from key released events.- Specified by:
removeKeyReleasedListenerin interfaceIKeyboard- Parameters:
keyCode- The keyCode for which to remove the listener.listener- The listener to remove.
-
onKeyTyped
Description copied from interface:IKeyboardAdds the specified key typed listener to receive events when the key with the definedkeyCodehas been typed.- Specified by:
onKeyTypedin interfaceIKeyboard- Parameters:
keyCode- The keyCode to capture the key typed event for.listener- The listener to add.- See Also:
-
removeKeyTypedListener
Description copied from interface:IKeyboardUnregister the specified listener from key typed events.- Specified by:
removeKeyTypedListenerin interfaceIKeyboard- Parameters:
keyCode- The keyCode for which to remove the listener.listener- The listener to remove.
-
onKeyPressed
Description copied from interface:IKeyboardAdds the specified key pressed listener to receive events when any key has been pressed.- Specified by:
onKeyPressedin interfaceIKeyboard- Parameters:
listener- The listener to add.- See Also:
-
removeKeyPressedListener
Description copied from interface:IKeyboardUnregister the specified listener from key pressed events.- Specified by:
removeKeyPressedListenerin interfaceIKeyboard- Parameters:
listener- The listener to remove.
-
onKeyReleased
Description copied from interface:IKeyboardAdds the specified key released listener to receive events when any key has been released.- Specified by:
onKeyReleasedin interfaceIKeyboard- Parameters:
listener- The listener to add.- See Also:
-
removeKeyReleasedListener
Description copied from interface:IKeyboardUnregister the specified listener from key released events.- Specified by:
removeKeyReleasedListenerin interfaceIKeyboard- Parameters:
listener- The listener to remove.
-
onKeyTyped
Description copied from interface:IKeyboardAdds the specified key typed listener to receive events when any key has been typed.- Specified by:
onKeyTypedin interfaceIKeyboard- Parameters:
listener- The listener to add.- See Also:
-
removeKeyTypedListener
Description copied from interface:IKeyboardUnregister the specified listener from key typed events.- Specified by:
removeKeyTypedListenerin interfaceIKeyboard- Parameters:
listener- The listener to remove.
-
clearExplicitListeners
public void clearExplicitListeners()Description copied from interface:IKeyboardRemoves all registered event consumers from the Keyboard instance. This does not affect registeredKeyListenerinstances.- Specified by:
clearExplicitListenersin interfaceIKeyboard- See Also:
-
addKeyListener
Description copied from interface:IKeyboardRegister for key events.- Specified by:
addKeyListenerin interfaceIKeyboard- Parameters:
listener- The listener to add.
-
removeKeyListener
Description copied from interface:IKeyboardUnregister the specified listener from key events.- Specified by:
removeKeyListenerin interfaceIKeyboard- Parameters:
listener- The listener to remove.
-
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also:
-