Package rs.kreme.ksbot.api.hooks
Class Keyboard
- java.lang.Object
-
- rs.kreme.ksbot.api.hooks.Keyboard
-
public class Keyboard extends java.lang.Object
Provides methods for simulating keyboard input by dispatchingKeyEvent
events 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()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
pressed(int keyCode)
Simulates a key press event with the given key code.void
pressed(int keyCode, char keyChar)
Simulates a key press event with the given key code and key character.void
released(int keyCode)
Simulates a key release event with the given key code.void
released(int keyCode, char keyChar)
Simulates a key release event with both key code and character.void
sendEnter()
Simulates pressing the Enter key.void
sendSpace()
Simulates pressing the Space key.void
type(char c)
Simulates a full keystroke for a single character (press, type, and release).void
type(int number)
Types an integer by converting it to a string and sending each character as keystrokes.void
type(java.lang.String text)
Types a string of characters one by one.void
type(java.lang.String text, boolean sendEnter)
Types a string of characters and optionally presses Enter at the end.void
typed(int keyCode)
Simulates a key typed event using only the key code.void
typed(int keyCode, char keyChar)
Simulates a key typed event using the given key code and key character.
-
-
-
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
-
sendEnter
public void sendEnter()
Simulates pressing the Enter key.
-
sendSpace
public void sendSpace()
Simulates pressing the Space key.
-
-