Input

Input handles user interaction and events such as keypresses.

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
void process_events()
public static void Input.ProcessEvents();
public static void SplashKit.ProcessEvents();
procedure ProcessEvents()
def process_events():

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

True if the application has been requested to close.

Signatures
bool quit_requested()
public static bool Input.QuitRequested();
public static bool SplashKit.QuitRequested();
function QuitRequested(): Boolean
def quit_requested():

Reset Quit

Cancels a quit request, ensuring the quit requested will return false.

Signatures
void reset_quit()
public static void Input.ResetQuit();
public static void SplashKit.ResetQuit();
procedure ResetQuit()
def reset_quit():

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
void draw_collected_text(color clr, font fnt, int font_size, const drawing_options &opts)
public static void SplashKit.DrawCollectedText(Color clr, Font fnt, int fontSize, DrawingOptions opts);
procedure DrawCollectedText(clr: Color; fnt: Font; fontSize: Integer; const opts: DrawingOptions)
def draw_collected_text(clr, fnt, font_size, opts):

End Reading Text

This function is overloaded. The following versions exist.

End Reading Text

Ends reading text in for the current window.

Signatures
void end_reading_text()
public static void SplashKit.EndReadingText();
procedure EndReadingText()
def end_reading_text():

End Reading Text

Ends reading text for the passed in window.

Parameters
Name Type Description
Wind

Window

The window to end reading text

Signatures
void end_reading_text(window wind)
public static void SplashKit.EndReadingText(Window wind);
procedure EndReadingText(wind: Window)
def end_reading_text_in_window(wind):

Reading Text

This function is overloaded. The following versions exist.

Reading Text

Returns true when the current window is reading text.

Return Type

Boolean

True when window is setup to read input from the user.

Signatures
bool reading_text()
public static bool SplashKit.ReadingText();
function ReadingText(): Boolean
def reading_text():

Reading Text

Returns true when the window is reading text.

Return Type

Boolean

True when window is setup to read input from the user.

Parameters
Name Type Description
Wind

Window

The window to check

Signatures
bool reading_text(window wind)
public static bool SplashKit.ReadingText(Window wind);
function ReadingText(wind: Window): Boolean
def reading_text_in_window(wind):

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
void start_reading_text(rectangle rect)
public static void SplashKit.StartReadingText(Rectangle rect);
procedure StartReadingText(rect: Rectangle)
def start_reading_text(rect):

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
void start_reading_text(rectangle rect, string initial_text)
public static void SplashKit.StartReadingText(Rectangle rect, string initialText);
procedure StartReadingText(rect: Rectangle; initialText: String)
def start_reading_text_with_initial_text(rect, initial_text):

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
void start_reading_text(window wind, rectangle rect)
public static void SplashKit.StartReadingText(Window wind, Rectangle rect);
procedure StartReadingText(wind: Window; rect: Rectangle)
def start_reading_text_in_window(wind, rect):

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
void start_reading_text(window wind, rectangle rect, string initial_text)
public static void SplashKit.StartReadingText(Window wind, Rectangle rect, string initialText);
procedure StartReadingText(wind: Window; rect: Rectangle; initialText: String)
def start_reading_text_in_window_with_initial_text(wind, rect, initial_text):

Text Entry Cancelled

This function is overloaded. The following versions exist.

Text Entry Cancelled

Did the user press escape and cancel the enterring of text?

Return Type

Boolean

True when the use has cancelled text entry

Signatures
bool text_entry_cancelled()
public static bool SplashKit.TextEntryCancelled();
function TextEntryCancelled(): Boolean
def text_entry_cancelled():

Text Entry Cancelled

Did the user press escape and cancel the enterring of text?

Return Type

Boolean

True when the use has cancelled text entry

Parameters
Name Type Description
Wind

Window

The window to check

Signatures
bool text_entry_cancelled(window wind)
public static bool SplashKit.TextEntryCancelled(Window wind);
function TextEntryCancelled(wind: Window): Boolean
def text_entry_cancelled_in_window(wind):

Text Input

This function is overloaded. The following versions exist.

Text Input

The text the user has currently enterred on the current window.

Return Type

String

The user's text entry

Signatures
string text_input()
public static string SplashKit.TextInput();
function TextInput(): String
def text_input():

Text Input

The text the user has currently enterred on the current window.

Return Type

String

The user's text entry

Parameters
Name Type Description
Wind

Window

The window to check

Signatures
string text_input(window wind)
public static string SplashKit.TextInput(Window wind);
function TextInput(wind: Window): String
def text_input_in_window(wind):

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
void hide_mouse()
public static void SplashKit.HideMouse();
procedure HideMouse()
def hide_mouse():

Mouse Clicked

Returns true if the specified button was clicked since the last time Process Events was called.

Return Type

Boolean

True if the mouse button was clicked

Parameters
Name Type Description
Button

Mouse Button

The mouse button to check

Signatures
bool mouse_clicked(mouse_button button)
public static bool SplashKit.MouseClicked(MouseButton button);
function MouseClicked(button: MouseButton): Boolean
def mouse_clicked(button):

Mouse Down

Returns True if the specified button is currently pressed down.

Return Type

Boolean

True if the mouse button is down

Parameters
Name Type Description
Button

Mouse Button

The mouse button to check

Signatures
bool mouse_down(mouse_button button)
public static bool SplashKit.MouseDown(MouseButton button);
function MouseDown(button: MouseButton): Boolean
def mouse_down(button):

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

The movement of the mouse since the last process events

Signatures
vector_2d mouse_movement()
public static Vector2D SplashKit.MouseMovement();
function MouseMovement(): Vector2D
def mouse_movement():

Mouse Position

Returns the current window position of the mouse as a Point2d

Return Type

Point 2D

The position of the mouse in the current window.

Signatures
point_2d mouse_position()
public static Point2D SplashKit.MousePosition();
function MousePosition(): Point2D
def mouse_position():

Mouse Position Vector

Returns The current window position of the mouse as a Dynamic Array

Return Type

Vector 2D

The offset from the window origin to the mouse.

Signatures
vector_2d mouse_position_vector()
public static Vector2D SplashKit.MousePositionVector();
function MousePositionVector(): Vector2D
def mouse_position_vector():

Mouse Shown

Returns True if the mouse is currently visible, False if not.

Return Type

Boolean

True if the mouse is shown.

Signatures
bool mouse_shown()
public static bool SplashKit.MouseShown();
function MouseShown(): Boolean
def mouse_shown():

Mouse Up

Returns True if the specified button is currently up.

Return Type

Boolean

True if the mouse button is up (i.e. not down)

Parameters
Name Type Description
Button

Mouse Button

The mouse button to check

Signatures
bool mouse_up(mouse_button button)
public static bool SplashKit.MouseUp(MouseButton button);
function MouseUp(button: MouseButton): Boolean
def mouse_up(button):

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

The distance and direction of the mouse scroll since the last Process Events

Signatures
vector_2d mouse_wheel_scroll()
public static Vector2D SplashKit.MouseWheelScroll();
function MouseWheelScroll(): Vector2D
def mouse_wheel_scroll():

Mouse X

Returns the current x value of the mouse's position.

Return Type

Float

The distance of the mouse from the left edge of the current window location

Signatures
float mouse_x()
public static float SplashKit.MouseX();
function MouseX(): Single
def mouse_x():

Mouse Y

Returns the current y value of the mouse's position.

Return Type

Float

The distance of the mouse from the top edge of the current window location

Signatures
float mouse_y()
public static float SplashKit.MouseY();
function MouseY(): Single
def mouse_y():

Move Mouse

This function is overloaded. The following versions exist.

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
void move_mouse(double x, double y)
public static void SplashKit.MoveMouse(double x, double y);
procedure MoveMouse(x: Double; y: Double)
def move_mouse(x, y):

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
void move_mouse(point_2d point)
public static void SplashKit.MoveMouse(Point2D point);
procedure MoveMouse(point: Point2D)
def move_mouse_to_point(point):

Show Mouse

This function is overloaded. The following versions exist.

Show Mouse

Tells the mouse cursor to be visible if it was previously hidden with by a Hidemouse or Setmousevisible(False) call.

Signatures
void show_mouse()
public static void SplashKit.ShowMouse();
procedure ShowMouse()
def show_mouse():

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
void show_mouse(bool show)
public static void SplashKit.ShowMouse(bool show);
procedure ShowMouse(show: Boolean)
def show_mouse_with_boolean(show):

Any Key Pressed

Checks to see if any key has been pressed since the last time Process Events was called.

Return Type

Boolean

True if any key was pressed.

Signatures
bool any_key_pressed()
public static bool SplashKit.AnyKeyPressed();
function AnyKeyPressed(): Boolean
def any_key_pressed():

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
void deregister_callback_on_key_down(key_callback *callback)
public static void SplashKit.DeregisterCallbackOnKeyDown(KeyCallback callback);
procedure DeregisterCallbackOnKeyDown(callback: KeyCallback)
def deregister_callback_on_key_down(callback):

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
void deregister_callback_on_key_typed(key_callback *callback)
public static void SplashKit.DeregisterCallbackOnKeyTyped(KeyCallback callback);
procedure DeregisterCallbackOnKeyTyped(callback: KeyCallback)
def deregister_callback_on_key_typed(callback):

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
void deregister_callback_on_key_up(key_callback *callback)
public static void SplashKit.DeregisterCallbackOnKeyUp(KeyCallback callback);
procedure DeregisterCallbackOnKeyUp(callback: KeyCallback)
def deregister_callback_on_key_up(callback):

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.

Return Type

Boolean

True if the key is currently held down

Parameters
Name Type Description
Key

Key Code

The key to check if it is down

Signatures
bool key_down(key_code key)
public static bool SplashKit.KeyDown(KeyCode key);
function KeyDown(key: KeyCode): Boolean
def key_down(key):

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.

Return Type

String

The name of the key

Parameters
Name Type Description
Key

Key Code

The key to get the name of

Signatures
string key_name(key_code key)
public static string SplashKit.KeyName(KeyCode key);
function KeyName(key: KeyCode): String
def key_name(key):

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.

Return Type

Boolean

True if the key was just released

Parameters
Name Type Description
Key

Key Code

The key to check if it was released

Signatures
bool key_released(key_code key)
public static bool SplashKit.KeyReleased(KeyCode key);
function KeyReleased(key: KeyCode): Boolean
def key_released(key):

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

Return Type

Boolean

True if the key was just pressed down

Parameters
Name Type Description
Key

Key Code

The key to check if it was typed

Signatures
bool key_typed(key_code key)
public static bool SplashKit.KeyTyped(KeyCode key);
function KeyTyped(key: KeyCode): Boolean
def key_typed(key):

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.

Return Type

Boolean

True if the key is currently up

Parameters
Name Type Description
Key

Key Code

The key to check if it is up

Signatures
bool key_up(key_code key)
public static bool SplashKit.KeyUp(KeyCode key);
function KeyUp(key: KeyCode): Boolean
def key_up(key):

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
void register_callback_on_key_down(key_callback *callback)
public static void SplashKit.RegisterCallbackOnKeyDown(KeyCallback callback);
procedure RegisterCallbackOnKeyDown(callback: KeyCallback)
def register_callback_on_key_down(callback):

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
void register_callback_on_key_typed(key_callback *callback)
public static void SplashKit.RegisterCallbackOnKeyTyped(KeyCallback callback);
procedure RegisterCallbackOnKeyTyped(callback: KeyCallback)
def register_callback_on_key_typed(callback):

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
void register_callback_on_key_up(key_callback *callback)
public static void SplashKit.RegisterCallbackOnKeyUp(KeyCallback callback);
procedure RegisterCallbackOnKeyUp(callback: KeyCallback)
def register_callback_on_key_up(callback):

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

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.

Constants
Name Description
Unknown Key

The unknown key

Backspace Key

The backspace key

Tab Key

The tab key

Clear Key

The clear key

Return Key

The return key

Pause Key

The pause key

Escape Key

The escape key

Space Key

The space key

Exclaim Key

The exclaim key

Double Quote Key

The double quote key

Hash Key

The hash key

Dollar Key

The dollar key

Ampersand Key

The ampersand key

Quote Key

The quote key

Left Paren Key

The left paren key

Right Paren Key

The right paren key

Asterisk Key

The asterisk key

Plus Key

The plus key

Comma Key

The comma key

Minus Key

The minus key

Period Key

The period key

Slash Key

The slash key

Num 0 Key

The num 0 key

Num 1 Key

The num 1 key

Num 2 Key

The num 2 key

Num 3 Key

The num 3 key

Num 4 Key

The num 4 key

Num 5 Key

The num 5 key

Num 6 Key

The num 6 key

Num 7 Key

The num 7 key

Num 8 Key

The num 8 key

Num 9 Key

The num 9 key

Colon Key

The colon key

Semi Colon Key

The semi colon key

Less Key

The less key

Equals Key

The equals key

Greater Key

The greater key

Question Key

The question key

At Key

The at key

Left Bracket Key

The left bracket key

Backslash Key

The backslash () key

Right Bracket Key

The right bracket key

Caret Key

The caret (^) key

Underscore Key

The underscore (_) key

Backquote Key

The backquote (`) key

A Key

The a key

B Key

The b key

C Key

The c key

D Key

The d key

E Key

The e key

F Key

The f key

G Key

The g key

H Key

The h key

I Key

The i key

J Key

The j key

K Key

The k key

L Key

The l key

M Key

The m key

N Key

The n key

O Key

The o key

P Key

The p key

Q Key

The q key

R Key

The r key

S Key

The s key

T Key

The t key

U Key

The u key

V Key

The v key

W Key

The w key

X Key

The x key

Y Key

The y key

Z Key

The z key

Delete Key

The delete key

Keypad 0

The keypad 0 key

Keypad 1

The keypad 1 key

Keypad 2

The keypad 2 key

Keypad 3

The keypad 3 key

Keypad 4

The keypad 4 key

Keypad 5

The keypad 5 key

Keypad 6

The keypad 6 key

Keypad 7

The keypad 7 key

Keypad 8

The keypad 8 key

Keypad 9

The keypad 9 key

Keypad Period

The keypad period key

Keypad Divide

The keypad divide key

Keypad Multiply

The keypad multiply key

Keypad Minus

The keypad minus key

Keypad Plus

The keypad plus key

Keypad Enter

The keypad enter key

Keypad Equals

The keypad equals key

Up Key

The up key

Down Key

The down key

Right Key

The right key

Left Key

The left key

Insert Key

The insert key

Home Key

The home key

End Key

The end key

Page Up Key

The page up key

Page Down Key

The page down key

F1 Key

The f1 key

F2 Key

The f2 key

F3 Key

The f3 key

F4 Key

The f4 key

F5 Key

The f5 key

F6 Key

The f6 key

F7 Key

The f7 key

F8 Key

The f8 key

F9 Key

The f9 key

F10 Key

The f10 key

F11 Key

The f11 key

F12 Key

The f12 key

F13 Key

The f13 key

F14 Key

The f14 key

F15 Key

The f15 key

Num Lock Key

The num lock key

Caps Lock Key

The caps lock key

Scroll Lock Key

The scroll lock key

Right Shift Key

The right shift key

Left Shift Key

The left shift key

Right Ctrl Key

The right ctrl key

Left Ctrl Key

The left ctrl key

Right Alt Key

The right alt or option key

Left Alt Key

The left alt or option key

Left Super Key

The left super (windows or command) key

Right Super Key

The right super (windows or command) key

Mode Key

The mode key

Help Key

The help key

Sys Req Key

The sys req key

Menu Key

The menu key

Power Key

The power key

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.

Constants
Name 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