Keyboard Support

An end user can use the following keys to interact with the widget.

`
Key Action
Alt + ↓ Opens the drop-down list.
Alt + ↑ Closes the drop-down list.
Esc Closes the drop-down list and removes focus from the widget.
↑ / ↓ Moves focus to the previous/next item. Active only when the drop-down list is open.
Page Up / Page Down Moves focus to the first/last currently rendered item.
Enter or Space Selects the current item.
Backspace Unselects the last selected item.

You can implement a custom handler for a key using the registerKeyHandler(key, handler) method.

jQuery
JavaScript
function registerKeyHandlers () {
    let tagBox =  $("#tagBoxContainer").dxTagBox("instance");
    tagBox.registerKeyHandler("backspace", function (e) {
        // The argument "e" contains information on the event
    });
    tagBox.registerKeyHandler("space", function (e) {
        // ...
    });
}
Angular
TypeScript
import { ..., ViewChild } from '@angular/core';
import { DxTagBoxModule, DxTagBoxComponent } from 'devextreme-angular';
// ...
export class AppComponent {
    @ViewChild(DxTagBoxComponent) tagBox: DxTagBoxComponent
    registerKeyHandlers () {
        this.tagBox.instance.registerKeyHandler("backspace", function (e) {
            // The argument "e" contains information on the event
        });
        this.tagBox.instance.registerKeyHandler("space", function (e) {
            // ...
        });
    }
}
@NgModule({
    imports: [
        // ...
        DxTagBoxModule
    ],
    // ...
})
See Also