Class Keyboard

java.lang.Object
net.storm.sdk.input.Keyboard

public class Keyboard extends Object
Provides static utility methods for simulating keyboard input to the game client. This class allows sending key press, release, and type events, as well as convenience methods for typing strings and sending special keys.

Key events are dispatched directly to the game canvas, simulating user keyboard input.

Example usage:


 // Type a string into a chat box or input field
 Keyboard.type("Hello world");

 // Type a string and press Enter
 Keyboard.type("Hello world", true);

 // Type a number
 Keyboard.type(123);

 // Send individual key events
 Keyboard.pressed(KeyEvent.VK_ESCAPE);
 Keyboard.released(KeyEvent.VK_ESCAPE);

 // Send Enter key
 Keyboard.sendEnter();

 // Send Space key (useful for dialog continuation)
 Keyboard.sendSpace();

 // Type a single character
 Keyboard.type('a');
 
See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    pressed(int keyCode)
    Dispatches a key pressed event to the game canvas.
    static void
    pressed(int keyCode, char keyChar)
    Dispatches a key pressed event to the game canvas with a specific character.
    static void
    released(int keyCode)
    Dispatches a key released event to the game canvas.
    static void
    released(int keyCode, char keyChar)
    Dispatches a key released event to the game canvas with a specific character.
    static void
    Sends an Enter key press to the game client.
    static void
    Sends a Space key press to the game client.
    static void
    type(char c)
    Types a single character to the game client.
    static void
    type(int number)
    Types a number as a string to the game client.
    static void
    type(String text)
    Types a string to the game client.
    static void
    type(String text, boolean sendEnter)
    Types a string to the game client with an optional Enter key at the end.
    static void
    typed(int keyCode)
    Dispatches a key typed event to the game canvas.
    static void
    typed(int keyCode, char keyChar)
    Dispatches a key typed event to the game canvas with a specific character.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Keyboard

      public Keyboard()
  • Method Details

    • pressed

      public static void pressed(int keyCode)
      Dispatches a key pressed event to the game canvas. This simulates pressing down a key without releasing it.
      Parameters:
      keyCode - the key code constant from KeyEvent (e.g., KeyEvent.VK_ESCAPE)
    • pressed

      public static void pressed(int keyCode, char keyChar)
      Dispatches a key pressed event to the game canvas with a specific character.
      Parameters:
      keyCode - the key code constant from KeyEvent
      keyChar - the character associated with the key
    • typed

      public static void typed(int keyCode)
      Dispatches a key typed event to the game canvas. Key typed events are generated when a character is input.
      Parameters:
      keyCode - the key code constant from KeyEvent
    • typed

      public static void typed(int keyCode, char keyChar)
      Dispatches a key typed event to the game canvas with a specific character.
      Parameters:
      keyCode - the key code constant from KeyEvent
      keyChar - the character that was typed
    • released

      public static void released(int keyCode)
      Dispatches a key released event to the game canvas. This simulates releasing a previously pressed key.
      Parameters:
      keyCode - the key code constant from KeyEvent
    • released

      public static void released(int keyCode, char keyChar)
      Dispatches a key released event to the game canvas with a specific character.
      Parameters:
      keyCode - the key code constant from KeyEvent
      keyChar - the character associated with the key
    • type

      public static void type(char c)
      Types a single character to the game client. This is the fundamental method used by other type methods.
      Parameters:
      c - the character to type
    • type

      public static void type(int number)
      Types a number as a string to the game client. The number is converted to its string representation and typed character by character.
      Parameters:
      number - the number to type
    • type

      public static void type(String text)
      Types a string to the game client. Each character in the string is typed sequentially.
      Parameters:
      text - the text to type
    • type

      public static void type(String text, boolean sendEnter)
      Types a string to the game client with an optional Enter key at the end. Each character in the string is typed sequentially.
      Parameters:
      text - the text to type
      sendEnter - if true, sends an Enter key press after typing the text
    • sendEnter

      public static void sendEnter()
      Sends an Enter key press to the game client. Useful for confirming input in chat boxes, dialogs, or search fields.
    • sendSpace

      public static void sendSpace()
      Sends a Space key press to the game client. Useful for continuing dialogs or other space-triggered actions.