Package net.storm.sdk.input
Class Keyboard
java.lang.Object
net.storm.sdk.input.Keyboard
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidpressed(int keyCode) Dispatches a key pressed event to the game canvas.static voidpressed(int keyCode, char keyChar) Dispatches a key pressed event to the game canvas with a specific character.static voidreleased(int keyCode) Dispatches a key released event to the game canvas.static voidreleased(int keyCode, char keyChar) Dispatches a key released event to the game canvas with a specific character.static voidSends an Enter key press to the game client.static voidSends a Space key press to the game client.static voidtype(char c) Types a single character to the game client.static voidtype(int number) Types a number as a string to the game client.static voidTypes a string to the game client.static voidTypes a string to the game client with an optional Enter key at the end.static voidtyped(int keyCode) Dispatches a key typed event to the game canvas.static voidtyped(int keyCode, char keyChar) Dispatches a key typed event to the game canvas with a specific character.
-
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 fromKeyEvent(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 fromKeyEventkeyChar- 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 fromKeyEvent
-
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 fromKeyEventkeyChar- 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 fromKeyEvent
-
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 fromKeyEventkeyChar- 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
Types a string to the game client. Each character in the string is typed sequentially.- Parameters:
text- the text to type
-
type
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 typesendEnter- iftrue, 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.
-