KeyboardNavigatable
The KeyboardNavigatable
class manages lists that can be navigated with the
keyboard, calling callbacks for each actions.
This helper encapsulates the key binding logic, providing a simple fluent API for use.
Constructor Summary
Public Constructor | ||
public |
|
Member Summary
Public Members | ||
public |
Callback to be executed for a specified input. |
|
public |
whenCallback(event: KeyboardEvent): boolean: * Callback that determines whether keyboard input should be handled. |
Method Summary
Public Methods | ||
public |
bindTo($element: jQuery) Set up the navigation key bindings on the given jQuery element. |
|
public |
navigate(event: KeyboardEvent) Interpret the given keyboard event as navigation commands. |
|
public |
onCancel(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable Provide a callback to be executed when the navigation is canceled. |
|
public |
onDown(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable Provide a callback to be executed when navigating downwards. |
|
public |
onRemove(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable Provide a callback to be executed when previous input is removed. |
|
public |
onSelect(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable Provide a callback to be executed when the current item is selected.. |
|
public |
onUp(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable Provide a callback to be executed when navigating upwards. |
|
public |
when(callback: KeyboardNavigatable~whenCallback): KeyboardNavigatable Provide a callback that determines whether keyboard input should be handled. |
Public Constructors
public constructor() source
Public Members
Public Methods
public bindTo($element: jQuery) source
Set up the navigation key bindings on the given jQuery element.
Params:
Name | Type | Attribute | Description |
$element | jQuery |
public navigate(event: KeyboardEvent) source
Interpret the given keyboard event as navigation commands.
Params:
Name | Type | Attribute | Description |
event | KeyboardEvent |
public onCancel(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable source
Provide a callback to be executed when the navigation is canceled.
This will be triggered by the Escape key.
Params:
Name | Type | Attribute | Description |
callback | KeyboardNavigatable~keyCallback |
public onDown(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable source
Provide a callback to be executed when navigating downwards.
This will be triggered by the Down key.
Params:
Name | Type | Attribute | Description |
callback | KeyboardNavigatable~keyCallback |
public onRemove(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable source
Provide a callback to be executed when previous input is removed.
This will be triggered by the Backspace key.
Params:
Name | Type | Attribute | Description |
callback | KeyboardNavigatable~keyCallback |
public onSelect(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable source
Provide a callback to be executed when the current item is selected..
This will be triggered by the Return and Tab keys..
Params:
Name | Type | Attribute | Description |
callback | KeyboardNavigatable~keyCallback |
public onUp(callback: KeyboardNavigatable~keyCallback): KeyboardNavigatable source
Provide a callback to be executed when navigating upwards.
This will be triggered by the Up key.
Params:
Name | Type | Attribute | Description |
callback | KeyboardNavigatable~keyCallback |
public when(callback: KeyboardNavigatable~whenCallback): KeyboardNavigatable source
Provide a callback that determines whether keyboard input should be handled.
Params:
Name | Type | Attribute | Description |
callback | KeyboardNavigatable~whenCallback |