fuchsia.ui.input2

PROTOCOLS

Keyboard

Defined in fuchsia.ui.input2/keyboard.fidl

Components may request this service from their namespace to be notified of physical key events.

SetListener

Set key event listener for the specified View.

Request

NameType
view_ref fuchsia.ui.views/ViewRef
listener KeyListener

KeyListener

Defined in fuchsia.ui.input2/keyboard.fidl

Client should implement this protocol to get notified of key events. Returning HANDLED will stop event propagation to other clients. This notification is triggered on the following conditions: 1. Component is focused (ViewRef is on FocusChain) 2. Parent Views get the event first, child views last 3. Client returning HANDLED stops the propagation to subsequent clients

OnKeyEvent

Request

NameType
event KeyEvent

Response

NameType
result Status

ENUMS

KeyEventPhase

Type: uint32

Defined in fuchsia.ui.input2/events.fidl

Phase of the keyboard key input.

NameValueDescription
PRESSED 0
RELEASED 1

Status

Type: uint32

Defined in fuchsia.ui.input2/keyboard.fidl

Return type for clients key events listener.

NameValueDescription
HANDLED 1
NOT_HANDLED 2

Key

Type: uint32

Defined in fuchsia.ui.input2/keys.fidl

A Fuchsia key represents a control that can be pressed or released such as a button on a keyboard.

Where applicable, the definition of each key is derived from one of the following sources albeit with a Fuchsia-specific numeric value: - USB HID usage codes for usage page 0x0007 (Keyboard/Keypad) - USB HID usage codes for usage page 0x000c (Consumer) - Common but non-standard keys (vendor defined)

The example key mappings included in this documentation assume a US English keyboard layout. Actual behavior varies by layout.

NameValueDescription
A 1
B 2
C 3
D 4
E 5
F 6
G 7
H 8
I 9
J 10
K 11
L 12
M 13
N 14
O 15
P 16
Q 17
R 18
S 19
T 20
U 21
V 22
W 23
X 24
Y 25
Z 26
KEY_1 27
KEY_2 28
KEY_3 29
KEY_4 30
KEY_5 31
KEY_6 32
KEY_7 33
KEY_8 34
KEY_9 35
KEY_0 36
ENTER 37
ESCAPE 38
BACKSPACE 39
TAB 40
SPACE 41
MINUS 42
EQUALS 43
LEFT_BRACE 44
RIGHT_BRACE 45
BACKSLASH 46
NON_US_HASH 47
SEMICOLON 48
APOSTROPHE 49
GRAVE_ACCENT 50
COMMA 51
DOT 52
SLASH 53
CAPS_LOCK 54
F1 55
F2 56
F3 57
F4 58
F5 59
F6 60
F7 61
F8 62
F9 63
F10 64
F11 65
F12 66
PRINT_SCREEN 67
SCROLL_LOCK 68
PAUSE 69
INSERT 70
HOME 71
PAGE_UP 72
DELETE 73
END 74
PAGE_DOWN 75
RIGHT 76
LEFT 77
DOWN 78
UP 79
NON_US_BACKSLASH 80
LEFT_CTRL 81
LEFT_SHIFT 82
LEFT_ALT 83
LEFT_META 84
RIGHT_CTRL 85
RIGHT_SHIFT 86
RIGHT_ALT 87
RIGHT_META 88
NUM_LOCK 512
KEYPAD_SLASH 513
KEYPAD_ASTERISK 514
KEYPAD_MINUS 515
KEYPAD_PLUS 516
KEYPAD_ENTER 517
KEYPAD_1 518
KEYPAD_2 519
KEYPAD_3 520
KEYPAD_4 521
KEYPAD_5 522
KEYPAD_6 523
KEYPAD_7 524
KEYPAD_8 525
KEYPAD_9 526
KEYPAD_0 527
KEYPAD_DOT 528
MEDIA_MUTE 768
MEDIA_VOLUME_INCREMENT 769
MEDIA_VOLUME_DECREMENT 770

TABLES

KeyEvent

Defined in fuchsia.ui.input2/events.fidl

Keyboard event is generated to reflect key input.

OrdinalNameTypeDescription
1 key Key Physical key being pressed. Keyboard layout is applied (QWERTY/AZERTY/Dvorak/etc).
2 phase KeyEventPhase Phase of input.
3 modifiers Modifiers Modifier keys being held.

BITS

Modifiers

Type: uint32

NameValueDescription
SHIFT 1 Applies when either the `LEFT_SHIFT` or `RIGHT_SHIFT` modifier is pressed.
LEFT_SHIFT 2 Applies when the `LEFT_SHIFT` modifier is pressed.
RIGHT_SHIFT 4 Applies when the `RIGHT_SHIFT` modifier is pressed.
CONTROL 8 Applies when either the `LEFT_CONTROL` or `RIGHT_CONTROL` modifier is pressed.
LEFT_CONTROL 16 Applies when the `LEFT_CONTROL` modifier is pressed.
RIGHT_CONTROL 32 Applies when the `RIGHT_CONTROL` modifier is pressed.
ALT 64 Applies when either the `LEFT_ALT` or `RIGHT_ALT` modifier is pressed.
LEFT_ALT 128 Applies when the `LEFT_ALT` modifier is pressed.
RIGHT_ALT 256 Applies when the `RIGHT_ALT` modifier is pressed.
META 512 Applies when either the `LEFT_META` or `RIGHT_META` modifier is pressed.
LEFT_META 1024 Applies when the `LEFT_META` modifier is pressed.
RIGHT_META 2048 Applies when the `RIGHT_META` modifier is pressed.
CAPS_LOCK 4096 Applies when the `CAPS_LOCK` modifier is locked.
NUM_LOCK 8192 Applies when the `NUM_LOCK` modifier is locked.
SCROLL_LOCK 16384 Applies when the `SCROLL_LOCK` modifier is locked.