KeyboardManager

KeyboardManager

A set of helpers and management functions for dealing with user input from keyboard events. https://keycode.info/

Constructor

new KeyboardManager()

Source:

Members

(static) DIGIT_KEYS :Array

Source:

Enumerate the "digit keys"

Type:

(static) MOUSE_WHEEL_RATE_LIMIT :number

Source:

Specify a rate limit for mouse wheel to gate repeated scrolling. This is especially important for continuous scrolling mice which emit hundreds of events per second. This designates a minimum number of milliseconds which must pass before another wheel event is handled

Type:
  • number

(static) MOVEMENT_KEYS :Object

Source:

Map keys used for movement

Type:
  • Object

(static) ZOOM_KEYS :Object

Source:

Map keys used for canvas zooming

Type:
  • Object

_downKeys :Set

Source:

The set of key codes which are currently depressed (down)

Type:
  • Set

_handled :Set

Source:

The set of key codes which have been already handled per workflow

Type:
  • Set

digitKeys

Source:

The key codes which represent a digit key

hasFocus

Source:

Test whether an input currently has focus

moveKeys

Source:

The key codes which represent a possible movement key

zoomKeys

Source:

Return the key codes used for zooming the canvas

Methods

_handleCanvasPan()

Source:

Handle panning the canvas using CTRL + directional keys

_onCompositionEnd(event)

Source:

Input events do not fire with isComposing = false at the end of a composition event in Chrome See: https://github.com/w3c/uievents/issues/202

Parameters:
Name Type Description
event CompositionEvent

getKey(event) → {string}

Source:

Get a standardized keyboard code for a given event

Parameters:
Name Type Description
event KeyboardEvent

The originating keypress event

Returns:

The standardized string code to use

Type
string

isCtrl(event) → {Boolean}

Source:

A helper method to test whether, given an Event, the CTRL (or CMD) keys are pressed

Parameters:
Name Type Description
event
Returns:
Type
Boolean

isDown(code)

Source:

Return whether the key code is currently in the DOWN state

Parameters:
Name Type Description
code string

The key code to test