Package rs.kreme.ksbot.api.hooks
Class Keyboard
- java.lang.Object
-
- rs.kreme.ksbot.api.hooks.Keyboard
-
public class Keyboard extends java.lang.ObjectProvides methods for simulating keyboard input by dispatchingKeyEventevents directly to the RuneLite client's canvas.Supports low-level keyPressed, keyTyped, and keyReleased events as well as high-level string/char entry and utility methods for common keys (Enter, Space).
-
-
Constructor Summary
Constructors Constructor Description Keyboard(rs.kreme.ksbot.api.KSContext ctx)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidpressed(int keyCode)Simulates a key press event with the given key code.voidpressed(int keyCode, char keyChar)Simulates a key press event with the given key code and key character.voidreleased(int keyCode)Simulates a key release event with the given key code.voidreleased(int keyCode, char keyChar)Simulates a key release event with both key code and character.voidsendChatMessage(java.lang.String message)Opens the chat input field and types a message with human-like timing, then sends it.voidsendChatMessage(java.lang.String prefix, java.lang.String message)Opens the chat input field with a specific prefix (like '/', '//', etc.) and types a message with human-like timing, then sends it.voidsendEnter()Simulates pressing the Enter key.voidsendSpace()Simulates pressing the Space key.voidtype(char c)Simulates a full keystroke for a single character (press, type, and release).voidtype(int number)Types an integer by converting it to a string and sending each character as keystrokes.voidtype(java.lang.String text)Types a string of characters one by one.voidtype(java.lang.String text, boolean sendEnter)Types a string of characters and optionally presses Enter at the end.voidtyped(int keyCode)Simulates a key typed event using only the key code.voidtyped(int keyCode, char keyChar)Simulates a key typed event using the given key code and key character.voidtypeHumanLike(java.lang.String text, boolean sendEnter)Types a string with human-like delays between characters.
-
-
-
Method Detail
-
pressed
public void pressed(int keyCode)
Simulates a key press event with the given key code.- Parameters:
keyCode- the key code to press (e.g.,KeyEvent.VK_A)
-
pressed
public void pressed(int keyCode, char keyChar)Simulates a key press event with the given key code and key character.- Parameters:
keyCode- the key code to presskeyChar- the key character (orKeyEvent.CHAR_UNDEFINED)
-
typed
public void typed(int keyCode)
Simulates a key typed event using only the key code.- Parameters:
keyCode- the key code to simulate
-
typed
public void typed(int keyCode, char keyChar)Simulates a key typed event using the given key code and key character.- Parameters:
keyCode- the key codekeyChar- the key character
-
released
public void released(int keyCode)
Simulates a key release event with the given key code.- Parameters:
keyCode- the key code to release
-
released
public void released(int keyCode, char keyChar)Simulates a key release event with both key code and character.- Parameters:
keyCode- the key codekeyChar- the key character
-
type
public void type(char c)
Simulates a full keystroke for a single character (press, type, and release).- Parameters:
c- the character to type
-
type
public void type(int number)
Types an integer by converting it to a string and sending each character as keystrokes.- Parameters:
number- the number to type
-
type
public void type(java.lang.String text)
Types a string of characters one by one.- Parameters:
text- the text to type
-
type
public void type(java.lang.String text, boolean sendEnter)Types a string of characters and optionally presses Enter at the end.- Parameters:
text- the text to typesendEnter- true to press Enter after typing the string
-
typeHumanLike
public void typeHumanLike(java.lang.String text, boolean sendEnter)Types a string with human-like delays between characters.- Parameters:
text- the text to typesendEnter- true to press Enter after typing the string
-
sendChatMessage
public void sendChatMessage(java.lang.String message)
Opens the chat input field and types a message with human-like timing, then sends it.- Parameters:
message- the message to send
-
sendChatMessage
public void sendChatMessage(java.lang.String prefix, java.lang.String message)Opens the chat input field with a specific prefix (like '/', '//', etc.) and types a message with human-like timing, then sends it.- Parameters:
prefix- the chat prefix to use (e.g., "/" for public chat)message- the message to send
-
sendEnter
public void sendEnter()
Simulates pressing the Enter key.
-
sendSpace
public void sendSpace()
Simulates pressing the Space key.
-
-