Keyboard API
Category: API Reference
Simulate keyboard input with customizable typing speed profiles.
Functions
type_text
keyboard:type_text(text: string) -> ()
Type text with human-like delays between characters.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to type |
Example:
keyboard:type_text("Hello, RuneScape!")
type_text_instant
keyboard:type_text_instant(text: string) -> ()
Type text instantly without delays.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
text | string | Yes | Text to type |
key_press
keyboard:key_press(vk: number) -> ()
Press and release a key.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vk | number | Yes | Virtual key code |
Example:
keyboard:key_press(13) -- Press Enter
keyboard:key_press(27) -- Press Escape
key_down
keyboard:key_down(vk: number) -> ()
Press a key (hold down).
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vk | number | Yes | Virtual key code |
key_up
keyboard:key_up(vk: number) -> ()
Release a key.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vk | number | Yes | Virtual key code |
press_enter
keyboard:press_enter() -> ()
Press Enter key.
press_escape
keyboard:press_escape() -> ()
Press Escape key.
press_space
keyboard:press_space() -> ()
Press Space key.
press_tab
keyboard:press_tab() -> ()
Press Tab key.
press_backspace
keyboard:press_backspace() -> ()
Press Backspace key.
press_delete
keyboard:press_delete() -> ()
Press Delete key.
press_arrow_up
keyboard:press_arrow_up() -> ()
Press Up arrow.
press_arrow_down
keyboard:press_arrow_down() -> ()
Press Down arrow.
press_arrow_left
keyboard:press_arrow_left() -> ()
Press Left arrow.
press_arrow_right
keyboard:press_arrow_right() -> ()
Press Right arrow.
send_char
keyboard:send_char(char: string) -> ()
Send a single character.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
char | string | Yes | Single character to send |
ctrl_key
keyboard:ctrl_key(vk: number) -> ()
Press Ctrl+key combination.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vk | number | Yes | Virtual key code |
Example:
keyboard:ctrl_key(67) -- Ctrl+C
keyboard:ctrl_key(86) -- Ctrl+V
alt_key
keyboard:alt_key(vk: number) -> ()
Press Alt+key combination.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vk | number | Yes | Virtual key code |
shift_key
keyboard:shift_key(vk: number) -> ()
Press Shift+key combination.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
vk | number | Yes | Virtual key code |
set_typing_speed
keyboard:set_typing_speed(profile: string) -> ()
Set typing speed profile.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
profile | string | Yes | "fast", "slow", or "default" |
Example:
keyboard:set_typing_speed("slow") -- More human-like
keyboard:set_typing_speed("fast") -- Faster typing
clear_modifiers
keyboard:clear_modifiers() -> ()
Clear all modifier key states (Ctrl, Alt, Shift).
Common Patterns
Bank X Dialog
local function bank_x_amount(quantity)
-- Assuming Bank X dialog open
keyboard:type_text(tostring(quantity))
sleep(100)
keyboard:press_enter()
end
bank_x_amount(100) -- Deposit 100 items
Chatting
local function send_chat_message(message)
keyboard:type_text(message)
sleep(100)
keyboard:press_enter()
end
send_chat_message("Hello!")
Input Handling
local function wait_for_input_and_respond(prompt, response)
logger:info(prompt)
keyboard:type_text(response)
keyboard:press_enter()
end
wait_for_input_and_respond("Enter amount:", "50")
Hotkey Usage
local function use_hotkey(key_code)
keyboard:key_press(key_code)
sleep(100)
end
-- Use F1 hotkey
use_hotkey(112)
Virtual Key Codes
Common key codes:
- 8 - BACKSPACE
- 9 - TAB
- 13 - ENTER
- 16 - SHIFT
- 17 - CTRL
- 18 - ALT
- 27 - ESCAPE
- 32 - SPACE
- 37-40 - Arrow keys (LEFT, UP, RIGHT, DOWN)
- 65-90 - A-Z
- 48-57 - 0-9
- 112-123 - F1-F12
Related APIs
- Mouse API - Mouse input
- Chat API - Chat interactions