Project: /_project.yaml Book: /_book.yaml

fuchsia.ui.input2

PROTOCOLS

Keyboard {:#Keyboard}

Defined in fuchsia.ui.input2/keyboard.fidl

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

SetListener {:#SetListener}

Set key event listener for the specified View.

Request

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 {:#OnKeyEvent}

Request

Response

KeyboardLayoutState {:#KeyboardLayoutState}

Defined in fuchsia.ui.input2/layout.fidl

Input method editors should implement this protocol to populate KeyEvent.symbol field based on current key layout.

Watch {:#Watch}

Get current key layout. Returns immediately on first call; subsequent calls return when the value changes.

Request

Response

Keyboard {:#Keyboard}

Defined in fuchsia.ui.input2/keyboard.fidl

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

SetListener {:#SetListener}

Set key event listener for the specified View.

Request

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 {:#OnKeyEvent}

Request

Response

KeyboardLayoutState {:#KeyboardLayoutState}

Defined in fuchsia.ui.input2/layout.fidl

Input method editors should implement this protocol to populate KeyEvent.symbol field based on current key layout.

Watch {:#Watch}

Get current key layout. Returns immediately on first call; subsequent calls return when the value changes.

Request

Response

STRUCTS

PhysicalKeyMapEntry {:#PhysicalKeyMapEntry}

Defined in fuchsia.ui.input2/layout.fidl

A mapping of a physical key to a key.

SemanticKeyMapEntry {:#SemanticKeyMapEntry}

Defined in fuchsia.ui.input2/layout.fidl

A mapping of a key to the semantic meaning.

PhysicalKeyMapEntry {:#PhysicalKeyMapEntry}

Defined in fuchsia.ui.input2/layout.fidl

A mapping of a physical key to a key.

SemanticKeyMapEntry {:#SemanticKeyMapEntry}

Defined in fuchsia.ui.input2/layout.fidl

A mapping of a key to the semantic meaning.

ENUMS

KeyEventPhase {:#KeyEventPhase}

Type: uint32

Defined in fuchsia.ui.input2/events.fidl

Phase of the keyboard key input.

Status {:#Status}

Type: uint32

Defined in fuchsia.ui.input2/keyboard.fidl

Return type for clients key events listener.

Key {:#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.

SemanticKeyAction {:#SemanticKeyAction}

Type: uint32

Defined in fuchsia.ui.input2/semantic_keys.fidl

Semantic Key represents the meaning of a non-symbolic key on a keyboard.

Definition of each key is derived from W3C named values of a key attribute: https://www.w3.org/TR/uievents-key/#named-key-attribute-values

KeyEventPhase {:#KeyEventPhase}

Type: uint32

Defined in fuchsia.ui.input2/events.fidl

Phase of the keyboard key input.

Status {:#Status}

Type: uint32

Defined in fuchsia.ui.input2/keyboard.fidl

Return type for clients key events listener.

Key {:#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.

SemanticKeyAction {:#SemanticKeyAction}

Type: uint32

Defined in fuchsia.ui.input2/semantic_keys.fidl

Semantic Key represents the meaning of a non-symbolic key on a keyboard.

Definition of each key is derived from W3C named values of a key attribute: https://www.w3.org/TR/uievents-key/#named-key-attribute-values

TABLES

KeyEvent {:#KeyEvent}

Defined in fuchsia.ui.input2/events.fidl

Keyboard event is generated to reflect key input.

Use this value for the following purposes:

  • interpreting keyboard shortcuts such as CTRL+C

The input system derives this value from physical_key by consulting the physical key map of the KeyboardLayout that was active for the keyboard when when the key was pressed. Note that the same value will be reported when the key is released even if the keyboard layout changes in the interim between press and release.

Use this value for the following purposes:

  • typing text when implementing an input method editor (IME) or when IME services are not available (this won’t work for languages that require composition)

The input system derives this value from the combination of physical_key and modifiers by consulting the key symbol map of KeyboardLayout that was active for the keyboard when the key was pressed. Note that the same value will be reported when the key is released even if the keyboard layout or modifiers change in the interim between press and release.

Use this value for the following purposes:

  • applying keyboard layout translations
  • synthesizing input events into virtual machines, since VMs will do own layout mapping

The input system derives this value from the data reported by the keyboard itself without taking into account the keyboard’s current KeyboardLayout or modifiers.

KeyboardLayout {:#KeyboardLayout}

Defined in fuchsia.ui.input2/layout.fidl

Collection of key maps.

A physical key is first converted to key using key_map. The key is then used to populate symbol using symbol_map. Maps in KeySymbolMap should be searched for the key mapping in the order they are included. First key mapping found in an applicable map should be used. Only maps with matching modifiers should be used. See KeySymbolMap for modifiers matching criteria and examples.

PhysicalKeyMap {:#PhysicalKeyMap}

Defined in fuchsia.ui.input2/layout.fidl

Key map describes a conversion of a physical key to a key. Physical keys not included here are translated directly into keys.

SemanticKeyMap {:#SemanticKeyMap}

Defined in fuchsia.ui.input2/layout.fidl

Key map describes a conversion of a key to symbol representation.

The map should be validated using key event modifier states. Map is applied if every modifier in the ‘modifiers’ list is active, and all other active modifiers are members of the ‘optional_modifiers’ list. If a modifier is enabled and not listed in neither modifiers nor optional_modifiers, the map should be ignored.

Example: Keyboard has NumLock and CapsLock enabled, and user presses Shift + Key.A

Map1: modifiers: “CapsLock” optional_modifiers: “NumLock” Map2: modifiers: “Shift”, optional_modifiers: “NumLock”, “CapsLock”, “ScrollLock” Map3: modifiers: None optional_modifiers: “Shift”, “CapsLock”

Map1 should be ignored, since “Shift” is pressed but is not included in modifiers or optional_modifiers.

Map2 should be searched, since required “Shift” is enabled, and all other enabled modifiers are included in optional_modifiers.

Map3 should be ignored, since “NumLock” is enabled but not included in modifiers or optional_modifiers.

KeyEvent {:#KeyEvent}

Defined in fuchsia.ui.input2/events.fidl

Keyboard event is generated to reflect key input.

Use this value for the following purposes:

  • interpreting keyboard shortcuts such as CTRL+C

The input system derives this value from physical_key by consulting the physical key map of the KeyboardLayout that was active for the keyboard when when the key was pressed. Note that the same value will be reported when the key is released even if the keyboard layout changes in the interim between press and release.

Use this value for the following purposes:

  • typing text when implementing an input method editor (IME) or when IME services are not available (this won’t work for languages that require composition)

The input system derives this value from the combination of physical_key and modifiers by consulting the key symbol map of KeyboardLayout that was active for the keyboard when the key was pressed. Note that the same value will be reported when the key is released even if the keyboard layout or modifiers change in the interim between press and release.

Use this value for the following purposes:

  • applying keyboard layout translations
  • synthesizing input events into virtual machines, since VMs will do own layout mapping

The input system derives this value from the data reported by the keyboard itself without taking into account the keyboard’s current KeyboardLayout or modifiers.

KeyboardLayout {:#KeyboardLayout}

Defined in fuchsia.ui.input2/layout.fidl

Collection of key maps.

A physical key is first converted to key using key_map. The key is then used to populate symbol using symbol_map. Maps in KeySymbolMap should be searched for the key mapping in the order they are included. First key mapping found in an applicable map should be used. Only maps with matching modifiers should be used. See KeySymbolMap for modifiers matching criteria and examples.

PhysicalKeyMap {:#PhysicalKeyMap}

Defined in fuchsia.ui.input2/layout.fidl

Key map describes a conversion of a physical key to a key. Physical keys not included here are translated directly into keys.

SemanticKeyMap {:#SemanticKeyMap}

Defined in fuchsia.ui.input2/layout.fidl

Key map describes a conversion of a key to symbol representation.

The map should be validated using key event modifier states. Map is applied if every modifier in the ‘modifiers’ list is active, and all other active modifiers are members of the ‘optional_modifiers’ list. If a modifier is enabled and not listed in neither modifiers nor optional_modifiers, the map should be ignored.

Example: Keyboard has NumLock and CapsLock enabled, and user presses Shift + Key.A

Map1: modifiers: “CapsLock” optional_modifiers: “NumLock” Map2: modifiers: “Shift”, optional_modifiers: “NumLock”, “CapsLock”, “ScrollLock” Map3: modifiers: None optional_modifiers: “Shift”, “CapsLock”

Map1 should be ignored, since “Shift” is pressed but is not included in modifiers or optional_modifiers.

Map2 should be searched, since required “Shift” is enabled, and all other enabled modifiers are included in optional_modifiers.

Map3 should be ignored, since “NumLock” is enabled but not included in modifiers or optional_modifiers.

XUNIONS

SemanticKey {:#SemanticKey}

Defined in fuchsia.ui.input2/events.fidl

Semantic for a physical key typed by the user. For letter or symbolic keys, is a string representation of the key typed. For non-symbolic keys, is a SemanticKeyAction value corresponding to the key pressed.

Examples: Key.A: “a” or “A” in US key layout, depending on CapsLock and Shift Key.SPACE: " " Key.TAB: SemanticKeyAction.TAB Key.GRAVE_ACCENT: “`” or “]” or “<”, depending on key layout

SemanticKey {:#SemanticKey}

Defined in fuchsia.ui.input2/events.fidl

Semantic for a physical key typed by the user. For letter or symbolic keys, is a string representation of the key typed. For non-symbolic keys, is a SemanticKeyAction value corresponding to the key pressed.

Examples: Key.A: “a” or “A” in US key layout, depending on CapsLock and Shift Key.SPACE: " " Key.TAB: SemanticKeyAction.TAB Key.GRAVE_ACCENT: “`” or “]” or “<”, depending on key layout

BITS

Modifiers {:#Modifiers}

Type: uint32

Modifiers {:#Modifiers}

Type: uint32

CONSTANTS