documentationfor yFiles for HTML 3.0.0.2

KeyboardInputMode

An IInputMode that recognizes simple key events and invokes a registered action.

Inheritance Hierarchy
KeyboardInputMode
Implemented Interfaces

Remarks

This mode is exclusive by default.

Examples

Typically the KeyboardInputMode is installed as a child mode of a GraphEditorInputMode or GraphViewerInputMode and can be retrieved from the keyboardInputMode property.
Getting the KeyboardInputMode from its parent input mode
const keyboardInputMode = mode.keyboardInputMode
Adding a handler for a keyboard event
// Execute the command if the Insert key is pressed
graphEditorInputMode.keyboardInputMode.addKeyBinding(
  'Insert',
  ModifierKeys.NONE,
  () => {
    graphEditorInputMode.createNode(
      graphEditorInputMode.graphComponent!.viewport.center,
    )
  },
)
Adding a handler triggered by a keyboard event recognizer
// Fit graph into viewport if the Enter key is pressed
graphEditorInputMode.keyboardInputMode.addRecognizerBinding(
  (evt) => evt instanceof KeyEventArgs && evt.key === 'Enter',
  () => graphComponent.fitGraphBounds(),
)

Type Details

yFiles module
view

See Also

Constructors

Properties

Methods

Events