Class InputEvent.Key

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.client.event.InputEvent
net.neoforged.neoforge.client.event.InputEvent.Key
Enclosing class:
InputEvent

public static class InputEvent.Key extends InputEvent
Fired when a keyboard key input occurs, such as pressing, releasing, or repeating a key.

This event is not cancellable, and does not

invalid reference
have a result
.

This event is fired on the main Forge event bus, only on the logical client.

  • Field Details

    • key

      private final int key
    • scanCode

      private final int scanCode
    • action

      private final int action
    • modifiers

      private final int modifiers
  • Constructor Details

    • Key

      @Internal public Key(int key, int scanCode, int action, int modifiers)
  • Method Details

    • getKey

      public int getKey()
      Returns the GLFW (platform-agnostic) key code.
      Returns:
      the GLFW (platform-agnostic) key code
      See Also:
    • getScanCode

      public int getScanCode()
      Returns the platform-specific scan code.

      The scan code is unique for every key, regardless of whether it has a key code. Scan codes are platform-specific but consistent over time, so keys will have different scan codes depending on the platform but they are safe to save to disk as custom key bindings.

      Returns:
      the platform-specific scan code
      See Also:
    • getAction

      public int getAction()
      Returns the mouse button's action.
      Returns:
      the mouse button's action
      See Also:
    • getModifiers

      public int getModifiers()
      Returns a bit field representing the active modifier keys.
      Returns:
      a bit field representing the active modifier keys
      See Also: