KeyboardInput Class
The keyboard of the user agent (see UserInput.Keyboard). The keys are dispatched to the focused element of the top-level browsing context (or to the body of the focused document), as trusted keydown, keypress and keyup events, and the library runs their default actions: the insertion of the text of the key in a text control or in editable content, the deletion of Backspace and Delete, the sequential focus navigation of Tab, the activation of the focused element by Enter and Space, the caret movements of the arrow keys, Home and End, the close requests of Escape, and the clipboard shortcuts (Control or Meta with C, X and V). The modifier keys that are pressed are the modifiers of the events (and of the pointer events, see UserInput.Modifiers).
public sealed class KeyboardInputProperties
| Name | Description |
|---|---|
| PressedKeys | Gets the keys that are pressed (their key values), in the order they were pressed. |
PressedKeys
UserInput.Keyboard.csGets the keys that are pressed (their key values), in the order they were pressed.
public IReadOnlyList<string> PressedKeys { get; }Property value
Methods
| Name | Description |
|---|---|
| Down(KeyboardKey) | Presses a key described by the values of its keyboard events (see KeyboardInput.Down): its key value is used as is (the Shift key does not change it). |
| Down(string) | Presses a key: the keydown event, then the keypress event and the insertion of its text (a character key or Enter, not pressed with Control or Meta), or the default action of the key. A key that is already pressed repeats (the repeat attribute of the events is true). A letter pressed while Shift is pressed is an uppercase letter. |
| InsertText(string) | Inserts a text in the focused text control or editable content, as an input method that commits a text: the beforeinput and input events of an insertText edit, without keyboard events. |
| Press(string) | Presses and releases a key (see KeyboardInput.Down and KeyboardInput.Up). |
| Type(string) | Types a text: presses and releases the key of each character (a line feed or a carriage return is the Enter key). The characters that a US keyboard cannot type are typed as keys that have no code. |
| Up(KeyboardKey) | Releases a key described by the values of its keyboard events (see KeyboardInput.Up). |
| Up(string) | Releases a key: the keyup event. A key that is not pressed is released anyway. |
Down overloads
Down(KeyboardKey)
UserInput.Keyboard.csPresses a key described by the values of its keyboard events (see KeyboardInput.Down): its key value is used as is (the Shift key does not change it).
public void Down(KeyboardKey key)Parameters
keyKeyboardKey
Down(string)
UserInput.Keyboard.csPresses a key: the keydown event, then the keypress event and the insertion of its text (a character key or Enter, not pressed with Control or Meta), or the default action of the key. A key that is already pressed repeats (the repeat attribute of the events is true). A letter pressed while Shift is pressed is an uppercase letter.
Parameters
keystring- The key value (https://w3c.github.io/uievents-key/): a character (e.g.
a) or the name of a key (e.g.Enter,Shift,ArrowLeft).
InsertText(string)
UserInput.Keyboard.csPress(string)
UserInput.Keyboard.csPresses and releases a key (see KeyboardInput.Down and KeyboardInput.Up).
Parameters
keystring- The key value of the key.
Type(string)
UserInput.Keyboard.csUp overloads
Up(KeyboardKey)
UserInput.Keyboard.csReleases a key described by the values of its keyboard events (see KeyboardInput.Up).
public void Up(KeyboardKey key)Parameters
keyKeyboardKey
Up(string)
UserInput.Keyboard.csReleases a key: the keyup event. A key that is not pressed is released anyway.
Parameters
keystring- The key value of the key (see
KeyboardInput.Down).