Input
Struct · namespace System.Graphics · Since 0.45
struct InputWhat 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.
Fields
Section titled “Fields”| 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. |
MouseX
Section titled “MouseX”int MouseXThe position of the mouse in pixels of the frame (-1 when it is outside).
MouseY
Section titled “MouseY”int MouseYThe position of the mouse in pixels of the frame (-1 when it is outside).
MouseDown
Section titled “MouseDown”bool MouseDownThe left mouse button is held down.
MousePressed
Section titled “MousePressed”bool MousePressedThe left button went down since the last frame.
MouseReleased
Section titled “MouseReleased”bool MouseReleasedThe left button went up since the last frame (with MousePressed: a click within one frame).
RightDown
Section titled “RightDown”bool RightDownThe right mouse button is held down (on AmigaOS the menu button).
RightPressed
Section titled “RightPressed”bool RightPressedThe right button went down since the last frame.
RightReleased
Section titled “RightReleased”bool RightReleasedThe right button went up since the last frame.
MiddleDown
Section titled “MiddleDown”bool MiddleDownThe middle mouse button (the wheel) is held down.
MiddlePressed
Section titled “MiddlePressed”bool MiddlePressedThe middle button went down since the last frame.
MiddleReleased
Section titled “MiddleReleased”bool MiddleReleasedThe middle button went up since the last frame.
int WheelThe mouse wheel, in notches since the last frame: positive when turned away from the user (scroll up).
WheelX
Section titled “WheelX”int WheelXThe 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> KeysThe keys pressed since the last frame, in order, including the repeats of a key that is held.
List<Key> HeldThe 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).
HeldBefore
Section titled “HeldBefore”List<Key> HeldBeforeThe 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
Section titled “Modifiers”List<KeyModifiers> ModifiersThe 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 TextThe characters typed since the last frame (UTF-8); a window leaves out what was typed with Ctrl.
bool CtrlA 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 ShiftA Shift key is held down, or was held with a key pressed since the last frame.
bool AltAn Alt key is held down, or was held with a key pressed since the last frame.
double TimeSeconds 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).
Steady
Section titled “Steady”bool SteadyThe 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.
CloseRequested
Section titled “CloseRequested”bool CloseRequestedThe 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.
Static methods
Section titled “Static methods”| Name | Description |
|---|---|
Create |
No mouse button, no keys, the mouse outside of everything. |
Create
Section titled “Create”static Input Create()No mouse button, no keys, the mouse outside of everything.
Methods
Section titled “Methods”| 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). |
IsDown
Section titled “IsDown”bool IsDown(Key key)True while the key is held down (a game moves while an arrow key is held). See Input.Held.
JustPressed
Section titled “JustPressed”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.
JustReleased
Section titled “JustReleased”bool JustReleased(Key key)True if the key went up in this frame.
MousePosition
Section titled “MousePosition”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.
Pressed
Section titled “Pressed”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.
ModifiersAt
Section titled “ModifiersAt”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).
HeldModifiers
Section titled “HeldModifiers”KeyModifiers HeldModifiers()Ctrl, Shift and Alt as KeyModifiers.
AddKey
Section titled “AddKey”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).