Interface IKeyboard

All Known Implementing Classes:
Keyboard

public interface IKeyboard
The IKeyboard interface is the engine's API for receiving keyboard input events.
  • 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 specified keyCode 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 specified keyCode 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

      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.
      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

      void removeKeyPressedListener​(int keyCode, IKeyboard.KeyPressedListener listener)
      Unregister the specified listener from key pressed events.
      Parameters:
      keyCode - The keyCode for which to remove the listener.
      listener - The listener to remove.
    • onKeyReleased

      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.
      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

      void removeKeyReleasedListener​(int keyCode, IKeyboard.KeyReleasedListener listener)
      Unregister the specified listener from key released events.
      Parameters:
      keyCode - The keyCode for which to remove the listener.
      listener - The listener to remove.
    • onKeyTyped

      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.
      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

      void removeKeyTypedListener​(int keyCode, IKeyboard.KeyTypedListener listener)
      Unregister the specified listener from key typed events.
      Parameters:
      keyCode - The keyCode for which to remove the listener.
      listener - The listener to remove.
    • onKeyPressed

      void onKeyPressed​(IKeyboard.KeyPressedListener listener)
      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

      void removeKeyPressedListener​(IKeyboard.KeyPressedListener listener)
      Unregister the specified listener from key pressed events.
      Parameters:
      listener - The listener to remove.
    • onKeyReleased

      void onKeyReleased​(IKeyboard.KeyReleasedListener listener)
      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

      void removeKeyReleasedListener​(IKeyboard.KeyReleasedListener listener)
      Unregister the specified listener from key released events.
      Parameters:
      listener - The listener to remove.
    • onKeyTyped

      void onKeyTyped​(IKeyboard.KeyTypedListener listener)
      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

      void removeKeyTypedListener​(IKeyboard.KeyTypedListener listener)
      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 registered KeyListener instances.
      See Also:
      onKeyPressed(KeyPressedListener), onKeyPressed(int, KeyPressedListener), onKeyReleased(KeyReleasedListener), onKeyReleased(int, KeyReleasedListener), onKeyTyped(KeyTypedListener), onKeyTyped(int, KeyTypedListener)
    • 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.