Reference Source
import KeyboardNavigatable from 'flarum/forum/utils/KeyboardNavigatable'
public class | source

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

Callback that determines whether keyboard input should be handled.

Method Summary

Public Methods
public

bindTo($element: undefined)

Set up the navigation key bindings on the given jQuery element.

public

Interpret the given keyboard event as navigation commands.

public

onCancel(callback: undefined): *

Provide a callback to be executed when the navigation is canceled.

public

onDown(callback: undefined): *

Provide a callback to be executed when navigating downwards.

public

onRemove(callback: undefined): *

Provide a callback to be executed when previous input is removed.

public

onSelect(callback: undefined): *

Provide a callback to be executed when the current item is selected..

public

onUp(callback: undefined): *

Provide a callback to be executed when navigating upwards.

public

when(callback: undefined): *

Provide a callback that determines whether keyboard input should be handled.

Public Constructors

public constructor() source

Public Members

public callbacks: * source

Callback to be executed for a specified input.

public whenCallback: * source

Callback that determines whether keyboard input should be handled. By default, always handle keyboard navigation.

Public Methods

public bindTo($element: undefined) source

Set up the navigation key bindings on the given jQuery element.

Params:

NameTypeAttributeDescription
$element undefined

public navigate(event: undefined) source

Interpret the given keyboard event as navigation commands.

Params:

NameTypeAttributeDescription
event undefined

public onCancel(callback: undefined): * source

Provide a callback to be executed when the navigation is canceled.

This will be triggered by the Escape key.

Params:

NameTypeAttributeDescription
callback undefined

Return:

*

public onDown(callback: undefined): * source

Provide a callback to be executed when navigating downwards.

This will be triggered by the Down key.

Params:

NameTypeAttributeDescription
callback undefined

Return:

*

public onRemove(callback: undefined): * source

Provide a callback to be executed when previous input is removed.

This will be triggered by the Backspace key.

Params:

NameTypeAttributeDescription
callback undefined

Return:

*

public onSelect(callback: undefined): * source

Provide a callback to be executed when the current item is selected..

This will be triggered by the Return and Tab keys..

Params:

NameTypeAttributeDescription
callback undefined

Return:

*

public onUp(callback: undefined): * source

Provide a callback to be executed when navigating upwards.

This will be triggered by the Up key.

Params:

NameTypeAttributeDescription
callback undefined

Return:

*

public when(callback: undefined): * source

Provide a callback that determines whether keyboard input should be handled.

Params:

NameTypeAttributeDescription
callback undefined

Return:

*