Skip to content
CShift0.45

Input

Struct · namespace System.Graphics · Since 0.45

struct Input

What the user did since the last frame: the state of the mouse and the keys that were pressed. A Window fills it in (Window.Input); for tests and screenshots a program can make its own.

Name Description
MouseX The position of the mouse in pixels of the frame (-1 when it is outside).
MouseY The position of the mouse in pixels of the frame (-1 when it is outside).
MouseDown The left mouse button is held down.
MousePressed The left button went down since the last frame.
MouseReleased The left button went up since the last frame (with MousePressed: a click within one frame).
RightDown The right mouse button is held down (on AmigaOS the menu button).
RightPressed The right button went down since the last frame.
RightReleased The right button went up since the last frame.
MiddleDown The middle mouse button (the wheel) is held down.
MiddlePressed The middle button went down since the last frame.
MiddleReleased The middle button went up since the last frame.
Wheel The mouse wheel, in notches since the last frame: positive when turned away from the user (scroll up).
WheelX The horizontal wheel (tilting it, or the sideways swipe of a touchpad), in notches since the last frame: positive to the right.
Keys The keys pressed since the last frame, in order, including the repeats of a key that is held.
Held The keys that are held down at the end of the frame (a game walks while an arrow key is held), without the modifier keys (see Input.Ctrl).
HeldBefore The keys that were held at the frame before (Input.Held of the last Window.Input): with Held it tells which keys went down or up in this frame (Input.JustPressed, Input.JustReleased).
Modifiers The modifier keys held at each key of Input.Keys, in the same order (a Window fills it in; use Input.AddKey to add a key with its modifiers).
Text The characters typed since the last frame (UTF-8); a window leaves out what was typed with Ctrl.
Ctrl A Ctrl key is held down, or was held with a key pressed since the last frame (so that Ctrl && Pressed(Key.S) also sees a quick Ctrl+S that ended before the frame; Input.Pressed with modifiers is exact).
Shift A Shift key is held down, or was held with a key pressed since the last frame.
Alt An Alt key is held down, or was held with a key pressed since the last frame.
Time Seconds since an arbitrary moment, from a monotonic clock (for animations, the blinking of the text cursor, the delay of tooltips).
Steady The window draws slowly (AmigaOS): the Ui asks for no frames of its own - the text cursor does not blink and tooltips show at once.
CloseRequested The user asked to close the window (its close button, Alt+F4, the close gadget) and the window was told to ask first (Window.ConfirmClose): it is still open.
int MouseX

The position of the mouse in pixels of the frame (-1 when it is outside).

int MouseY

The position of the mouse in pixels of the frame (-1 when it is outside).

bool MouseDown

The left mouse button is held down.

bool MousePressed

The left button went down since the last frame.

bool MouseReleased

The left button went up since the last frame (with MousePressed: a click within one frame).

bool RightDown

The right mouse button is held down (on AmigaOS the menu button).

bool RightPressed

The right button went down since the last frame.

bool RightReleased

The right button went up since the last frame.

bool MiddleDown

The middle mouse button (the wheel) is held down.

bool MiddlePressed

The middle button went down since the last frame.

bool MiddleReleased

The middle button went up since the last frame.

int Wheel

The mouse wheel, in notches since the last frame: positive when turned away from the user (scroll up).

int WheelX

The horizontal wheel (tilting it, or the sideways swipe of a touchpad), in notches since the last frame: positive to the right. 0 where the window does not report it (AmigaOS).

List<Key> Keys

The keys pressed since the last frame, in order, including the repeats of a key that is held.

List<Key> Held

The keys that are held down at the end of the frame (a game walks while an arrow key is held), without the modifier keys (see Input.Ctrl). Losing the focus lets them go. Empty where the window does not report it (AmigaOS, the browser with a cshift.js before 0.41).

List<Key> HeldBefore

The keys that were held at the frame before (Input.Held of the last Window.Input): with Held it tells which keys went down or up in this frame (Input.JustPressed, Input.JustReleased).

List<KeyModifiers> Modifiers

The modifier keys held at each key of Input.Keys, in the same order (a Window fills it in; use Input.AddKey to add a key with its modifiers). A key without an entry here, in an input that a program made, counts with the state of Ctrl, Shift and Alt.

string Text

The characters typed since the last frame (UTF-8); a window leaves out what was typed with Ctrl.

bool Ctrl

A Ctrl key is held down, or was held with a key pressed since the last frame (so that Ctrl && Pressed(Key.S) also sees a quick Ctrl+S that ended before the frame; Input.Pressed with modifiers is exact).

bool Shift

A Shift key is held down, or was held with a key pressed since the last frame.

bool Alt

An Alt key is held down, or was held with a key pressed since the last frame.

double Time

Seconds since an arbitrary moment, from a monotonic clock (for animations, the blinking of the text cursor, the delay of tooltips). 0 in an input that a program made itself (no clock).

bool Steady

The window draws slowly (AmigaOS): the Ui asks for no frames of its own - the text cursor does not blink and tooltips show at once. Ui.RequestFrame still works.

bool CloseRequested

The user asked to close the window (its close button, Alt+F4, the close gadget) and the window was told to ask first (Window.ConfirmClose): it is still open. The program asks the user, then closes it with Window.Close, or keeps it open by doing nothing.

Name Description
Create No mouse button, no keys, the mouse outside of everything.
static Input Create()

No mouse button, no keys, the mouse outside of everything.

Name Description
IsDown True while the key is held down (a game moves while an arrow key is held).
JustPressed True if the key went down in this frame: once per press, without the repeats of a held key (a game jumps once).
JustReleased True if the key went up in this frame.
MousePosition The position of the mouse in pixels of the window (-1, -1 when it is outside); Window.ToScreen gives it in pixels of a scaled picture.
Pressed True if the key was pressed since the last frame.
ModifiersAt The modifier keys held at the key index of Input.Keys (without an entry in Input.Modifiers: the state of Ctrl, Shift and Alt).
HeldModifiers Ctrl, Shift and Alt as KeyModifiers.
AddKey Adds a key press with the modifier keys held at it (for an input of your own: tests, a recorded input).
bool IsDown(Key key)

True while the key is held down (a game moves while an arrow key is held). See Input.Held.

bool JustPressed(Key key)

True if the key went down in this frame: once per press, without the repeats of a held key (a game jumps once). Input.Pressed counts the repeats, as typing does.

bool JustReleased(Key key)

True if the key went up in this frame.

Point MousePosition()

The position of the mouse in pixels of the window (-1, -1 when it is outside); Window.ToScreen gives it in pixels of a scaled picture.

bool Pressed(Key key)

True if the key was pressed since the last frame.

bool Pressed(Key key, KeyModifiers modifiers)

True if the key was pressed since the last frame with exactly these modifier keys held: a shortcut. Pressed(Key.S, KeyModifiers.Ctrl) is Ctrl+S, but not Ctrl+Shift+S; KeyModifiers.None is the key alone. It holds also when the whole shortcut (Ctrl down, S down and up, Ctrl up) was within one frame.

KeyModifiers ModifiersAt(int index)

The modifier keys held at the key index of Input.Keys (without an entry in Input.Modifiers: the state of Ctrl, Shift and Alt).

KeyModifiers HeldModifiers()

Ctrl, Shift and Alt as KeyModifiers.

void AddKey(Key key, KeyModifiers modifiers)

Adds a key press with the modifier keys held at it (for an input of your own: tests, a recorded input).