Input
Functions
Process Events
ProcessEvents allows SplashKit to react to user interactions. This procedure checks the current keyboard and mouse states and should be called once within your game loop to check user interaction.
Side Effects
- Reads user interaction events
- Updates keys down, text input, etc.
Signatures
Quit Requested
Checks to see if the user has asked for the application to quit. This
value is updated by the Process Events
routine. Also see
window_close_requested
.
Return Type - Boolean
Signatures
Reset Quit
Cancels a quit request, ensuring the quit requested will return false.
Signatures
Any Key Pressed
Checks to see if any key has been pressed since the last time
Process Events
was called.
Return Type - Boolean
Signatures
Deregister Callback On Key Down
Remove the registered callback from receiving events related to key down actions.
Parameters
Name | Type | Description |
---|---|---|
callback | Key Callback | The function to from from key down events |
Signatures
Deregister Callback On Key Typed
Remove the registered callback from receiving events related to key typed actions.
Parameters
Name | Type | Description |
---|---|---|
callback | Key Callback | The function to from from key typed events |
Signatures
Deregister Callback On Key Up
Remove the registered callback from receiving events related to key up actions.
Parameters
Name | Type | Description |
---|---|---|
callback | Key Callback | The function to from from key up events |
Signatures
Key Down
Returns true when the key requested is being held down. This is updated
as part of the Process Events
call. Use the key codes from Key Code
to specify the key to be checked.
Parameters
Name | Type | Description |
---|---|---|
key | Key Code | The key to check if it is down |
Return Type - Boolean
Signatures
Key Name
The Key Name
function returns a string name for a given Key Code
. For
example, COMMA_KEY
returns the string βCommaβ. This function could be used
to display more meaningful key names for configuring game controls, etc.
Parameters
Name | Type | Description |
---|---|---|
key | Key Code | The key to get the name of |
Return Type - String
Signatures
Key Released
Returns true if the specified key was released since the last time
Process Events
was called. This occurs only once for the key that is
released and will not return true again until the key is pressed down and
released again.
Parameters
Name | Type | Description |
---|---|---|
key | Key Code | The key to check if it was released |
Return Type - Boolean
Signatures
Key Typed
Returns true when the key requested is just pressed down. This is updated
as part of the Process Events
call. Use the key codes from Key Code
to specify the key to be checked. this will only occur once for that key that is
pressed and will not return true again until the key is released and presssed down again
Parameters
Name | Type | Description |
---|---|---|
key | Key Code | The key to check if it was typed |
Return Type - Boolean
Signatures
Key Up
Returns false when the key requested is being held down. This is updated
as part of the Process Events
call. Use the key codes from Key Code
to specify the key to be checked.
Parameters
Name | Type | Description |
---|---|---|
key | Key Code | The key to check if it is up |
Return Type - Boolean
Signatures
Register Callback On Key Down
Register the passed in callback function to receive notification of key down
calls. This will be called in response to Process Events
, for each key that
the user presses down.
Parameters
Name | Type | Description |
---|---|---|
callback | Key Callback | The function to be called when a key is first pressed |
Signatures
Register Callback On Key Typed
Register the passed in callback function to receive notification of key typed
calls. This will be called in response to Process Events
, when the user initially
presses a key down.
Parameters
Name | Type | Description |
---|---|---|
callback | Key Callback | The function to be called when a key is typed |
Signatures
Register Callback On Key Up
Register the passed in callback function to receive notification of key up
calls. This will be called in response to Process Events
, for each key that
the user releases.
Parameters
Name | Type | Description |
---|---|---|
callback | Key Callback | The function to be called when a key is released |
Signatures
Hide Mouse
Tells the mouse cursor to hide (no longer visible) if it is currently
showing. Use ShowMouse
to make the mouse cursor visible again.
Signatures
Mouse Clicked
Returns true if the specified button was clicked since the last time
Process Events
was called.
Parameters
Name | Type | Description |
---|---|---|
button | Mouse Button | The mouse button to check |
Return Type - Boolean
Signatures
Mouse Down
Returns true
if the specified button is currently pressed down.
Parameters
Name | Type | Description |
---|---|---|
button | Mouse Button | The mouse button to check |
Return Type - Boolean
Signatures
Mouse Movement
Returns the amount of accumulated mouse movement, since the last time
Process Events
was called, as a Vector 2d
.
Return Type - Vector 2d
Signatures
Mouse Position
Returns the current window position of the mouse as a Point2D
Return Type - Point 2d
Signatures
Mouse Position Vector
Returns The current window position of the mouse as a Vector
Return Type - Vector 2d
Signatures
Mouse Shown
Returns true
if the mouse is currently visible, false
if not.
Return Type - Boolean
Signatures
Mouse Up
Returns true
if the specified button is currently up.
Parameters
Name | Type | Description |
---|---|---|
button | Mouse Button | The mouse button to check |
Return Type - Boolean
Signatures
Mouse Wheel Scroll
Returns the amount the mouse wheel was scrolled since the last call
to Process Events
. The result is a vector containing the x and y
amounts scrolled. Scroll left generates a negative x, scroll right a
positive x. Scroll backward is negative y, scroll forward positive y.
Note that on MacOS the directions may be inverted by OS settings.
Return Type - Vector 2d
Signatures
Mouse X
Returns the current x value of the mouseβs position.
Return Type - Float
Signatures
Mouse Y
Returns the current y value of the mouseβs position.
Return Type - Float
Signatures
Move Mouse
Move Mouse
Moves the mouse cursor to the specified screen location.
Parameters
Name | Type | Description |
---|---|---|
x | Double | The new x location of the mouse |
y | Double | The new y location of the mouse |
Signatures
Move Mouse
Moves the mouse cursor to the specified screen location.
Parameters
Name | Type | Description |
---|---|---|
point | Point 2d | The new location of the mouse |
Signatures
Show Mouse
Show Mouse
Tells the mouse cursor to be visible if it was previously hidden with
by a HideMouse
or SetMouseVisible
(False) call.
Signatures
Show Mouse
Used to explicitly set the mouse cursors visible state (if it is showing in the window or not) based on the show parameter.
Parameters
Name | Type | Description |
---|---|---|
show | Boolean | When true the mouse is shown, when false it is hidden |
Signatures
Draw Collected Text
Draw the text that the user is currently enterring on the current window.
Parameters
Name | Type | Description |
---|---|---|
clr | Color | The color for the text |
fnt | Font | The font to use |
font_size | Integer | The size of the font |
opts | Drawing Options | Any drawing options |
Signatures
End Reading Text
End Reading Text
Ends reading text in for the current window.
Signatures
End Reading Text
Ends reading text for the passed in window.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window to end reading text |
Signatures
Reading Text
Reading Text
Returns true when the current window is reading text.
Return Type - Boolean
Signatures
Reading Text
Returns true when the window is reading text.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window to check |
Return Type - Boolean
Signatures
Start Reading Text
Start Reading Text
Start reading text in the current window within the bounds of the supplied rectangle.
Parameters
Name | Type | Description |
---|---|---|
rect | Rectangle | The area where the text will be entered. |
Signatures
Start Reading Text
Start reading text in the current window within the bounds of the supplied rectangle. The text will start with an initial value.
Parameters
Name | Type | Description |
---|---|---|
rect | Rectangle | The area where the text will be entered. |
initial_text | String | The initial text, which may be edited by the user. |
Signatures
Start Reading Text
Start reading text in the window within the bounds of the supplied rectangle.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window where the text will be entered |
rect | Rectangle | The area where the text will be entered. |
Signatures
Start Reading Text
Start reading text in the window within the bounds of the supplied rectangle. The text will start with an initial value.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window where the text will be entered |
rect | Rectangle | The area where the text will be entered. |
initial_text | String | The initial text, which may be edited by the user. |
Signatures
Text Entry Cancelled
Text Entry Cancelled
Did the user press escape and cancel the enterring of text?
Return Type - Boolean
Signatures
Text Entry Cancelled
Did the user press escape and cancel the enterring of text?
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window to check |
Return Type - Boolean
Signatures
Text Input
Text Input
The text the user has currently enterred on the current window.
Return Type - String
Signatures
Text Input
The text the user has currently enterred on the current window.
Parameters
Name | Type | Description |
---|---|---|
wind | Window | The window to check |
Return Type - String
Signatures
Types
Key Callback
The Key Callback
is a function pointer used to register your code with SplashKit
or keyboard related events. See Register Callback On Key Down
,
Register Callback On Key Up
, and Register Callback On Key Typed
The Key Callback
is a function pointer used to register your code with SplashKit
or keyboard related events. See Register Callback On Key Down
,
Register Callback On Key Up
, and Register Callback On Key Typed
Key Code
These are the key codes you can use to check details of keyboard actions.
See Key Down
, Key Up
, Key Typed
, and Key Released
functions.
You can get a string representation of these keys using Key Name
.
Constant | Value | Description |
---|---|---|
UNKNOWN_KEY | 0 | The unknown key |
BACKSPACE_KEY | 8 | The backspace key |
TAB_KEY | 9 | The tab key |
CLEAR_KEY | 12 | The clear key |
RETURN_KEY | 13 | The return key |
PAUSE_KEY | 19 | The pause key |
ESCAPE_KEY | 27 | The escape key |
SPACE_KEY | 32 | The space key |
EXCLAIM_KEY | 33 | The exclaim key |
DOUBLE_QUOTE_KEY | 34 | The double quote key |
HASH_KEY | 35 | The hash key |
DOLLAR_KEY | 36 | The dollar key |
AMPERSAND_KEY | 38 | The ampersand key |
QUOTE_KEY | 39 | The quote key |
LEFT_PAREN_KEY | 40 | The left paren key |
RIGHT_PAREN_KEY | 41 | The right paren key |
ASTERISK_KEY | 42 | The asterisk key |
PLUS_KEY | 43 | The plus key |
COMMA_KEY | 44 | The comma key |
MINUS_KEY | 45 | The minus key |
PERIOD_KEY | 46 | The period key |
SLASH_KEY | 47 | The slash key |
NUM_0_KEY | 48 | The num 0 key |
NUM_1_KEY | 49 | The num 1 key |
NUM_2_KEY | 50 | The num 2 key |
NUM_3_KEY | 51 | The num 3 key |
NUM_4_KEY | 52 | The num 4 key |
NUM_5_KEY | 53 | The num 5 key |
NUM_6_KEY | 54 | The num 6 key |
NUM_7_KEY | 55 | The num 7 key |
NUM_8_KEY | 56 | The num 8 key |
NUM_9_KEY | 57 | The num 9 key |
COLON_KEY | 58 | The colon key |
SEMI_COLON_KEY | 59 | The semi colon key |
LESS_KEY | 60 | The less key |
EQUALS_KEY | 61 | The equals key |
GREATER_KEY | 62 | The greater key |
QUESTION_KEY | 63 | The question key |
AT_KEY | 64 | The at key |
LEFT_BRACKET_KEY | 91 | The left bracket key |
BACKSLASH_KEY | 92 | The backslash () key |
RIGHT_BRACKET_KEY | 93 | The right bracket key |
CARET_KEY | 94 | The caret (^) key |
UNDERSCORE_KEY | 95 | The underscore (_) key |
BACKQUOTE_KEY | 96 | The backquote (`) key |
A_KEY | 97 | The a key |
B_KEY | 98 | The b key |
C_KEY | 99 | The c key |
D_KEY | 100 | The d key |
E_KEY | 101 | The e key |
F_KEY | 102 | The f key |
G_KEY | 103 | The g key |
H_KEY | 104 | The h key |
I_KEY | 105 | The i key |
J_KEY | 106 | The j key |
K_KEY | 107 | The k key |
L_KEY | 108 | The l key |
M_KEY | 109 | The m key |
N_KEY | 110 | The n key |
O_KEY | 111 | The o key |
P_KEY | 112 | The p key |
Q_KEY | 113 | The q key |
R_KEY | 114 | The r key |
S_KEY | 115 | The s key |
T_KEY | 116 | The t key |
U_KEY | 117 | The u key |
V_KEY | 118 | The v key |
W_KEY | 119 | The w key |
X_KEY | 120 | The x key |
Y_KEY | 121 | The y key |
Z_KEY | 122 | The z key |
DELETE_KEY | 127 | The delete key |
KEYPAD_0 | 256 | The keypad 0 key |
KEYPAD_1 | 257 | The keypad 1 key |
KEYPAD_2 | 258 | The keypad 2 key |
KEYPAD_3 | 259 | The keypad 3 key |
KEYPAD_4 | 260 | The keypad 4 key |
KEYPAD_5 | 261 | The keypad 5 key |
KEYPAD_6 | 262 | The keypad 6 key |
KEYPAD_7 | 263 | The keypad 7 key |
KEYPAD_8 | 264 | The keypad 8 key |
KEYPAD_9 | 265 | The keypad 9 key |
KEYPAD_PERIOD | 266 | The keypad period key |
KEYPAD_DIVIDE | 267 | The keypad divide key |
KEYPAD_MULTIPLY | 268 | The keypad multiply key |
KEYPAD_MINUS | 269 | The keypad minus key |
KEYPAD_PLUS | 270 | The keypad plus key |
KEYPAD_ENTER | 271 | The keypad enter key |
KEYPAD_EQUALS | 272 | The keypad equals key |
UP_KEY | 273 | The up key |
DOWN_KEY | 274 | The down key |
RIGHT_KEY | 275 | The right key |
LEFT_KEY | 276 | The left key |
INSERT_KEY | 277 | The insert key |
HOME_KEY | 278 | The home key |
END_KEY | 279 | The end key |
PAGE_UP_KEY | 280 | The page up key |
PAGE_DOWN_KEY | 281 | The page down key |
F1_KEY | 282 | The f1 key |
F2_KEY | 283 | The f2 key |
F3_KEY | 284 | The f3 key |
F4_KEY | 285 | The f4 key |
F5_KEY | 286 | The f5 key |
F6_KEY | 287 | The f6 key |
F7_KEY | 288 | The f7 key |
F8_KEY | 289 | The f8 key |
F9_KEY | 290 | The f9 key |
F10_KEY | 291 | The f10 key |
F11_KEY | 292 | The f11 key |
F12_KEY | 293 | The f12 key |
F13_KEY | 294 | The f13 key |
F14_KEY | 295 | The f14 key |
F15_KEY | 296 | The f15 key |
NUM_LOCK_KEY | 300 | The num lock key |
CAPS_LOCK_KEY | 301 | The caps lock key |
SCROLL_LOCK_KEY | 302 | The scroll lock key |
RIGHT_SHIFT_KEY | 303 | The right shift key |
LEFT_SHIFT_KEY | 304 | The left shift key |
RIGHT_CTRL_KEY | 305 | The right ctrl key |
LEFT_CTRL_KEY | 306 | The left ctrl key |
RIGHT_ALT_KEY | 307 | The right alt or option key |
LEFT_ALT_KEY | 308 | The left alt or option key |
LEFT_SUPER_KEY | 311 | The left super (windows or command) key |
RIGHT_SUPER_KEY | 312 | The right super (windows or command) key |
MODE_KEY | 313 | The mode key |
HELP_KEY | 315 | The help key |
SYS_REQ_KEY | 317 | The sys req key |
MENU_KEY | 319 | The menu key |
POWER_KEY | 320 | The power key |
These are the key codes you can use to check details of keyboard actions.
See Key Down
, Key Up
, Key Typed
, and Key Released
functions.
You can get a string representation of these keys using Key Name
.
Mouse Button
A mouse can have many different types of buttons. Most people know about the simple Left and Right buttons, but there is also a Middle button (sometimes part of a scoll wheel), and possible side buttons.
Constant | Value | Description |
---|---|---|
NO_BUTTON | No mouse button | |
LEFT_BUTTON | The left mouse button | |
MIDDLE_BUTTON | The middle mouse button | |
RIGHT_BUTTON | The right mouse button | |
MOUSE_X1_BUTTON | The x1 mouse button | |
MOUSE_X2_BUTTON | The x2 mouse button |
A mouse can have many different types of buttons. Most people know about the simple Left and Right buttons, but there is also a Middle button (sometimes part of a scoll wheel), and possible side buttons.