DevExtreme React - Keyboard Support

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

Key Action
↑ / ↓ Scrolls the content up/down if the scrolling direction is "vertical" or "both".
Mouse Wheel + Shift or ← / → Scrolls the content left/right if the scrolling direction is "horizontal" or "both".
Page Up / Page Down Scrolls the content up/down by a whole page.
Home / End Scrolls the content to the top/bottom.

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

jQuery
JavaScript
function registerKeyHandlers () {
    let scrollView =  $("#scrollViewContainer").dxScrollView("instance");
    scrollView.registerKeyHandler("backspace", function (e) {
        // The argument "e" contains information on the event
    });
    scrollView.registerKeyHandler("space", function (e) {
        // ...
    });
}
Angular
TypeScript
import { ..., ViewChild, AfterViewInit } from "@angular/core";
import { DxScrollViewModule, DxScrollViewComponent } from "devextreme-angular";
// ...
export class AppComponent implements AfterViewInit {
    @ViewChild(DxScrollViewComponent) scrollView: DxScrollViewComponent
    ngAfterViewInit () {
        this.scrollView.instance.registerKeyHandler("backspace", function (e) {
            // The argument "e" contains information on the event
        });
        this.scrollView.instance.registerKeyHandler("space", function (e) {
            // ...
        });
    }
}
@NgModule({
    imports: [
        // ...
        DxScrollViewModule
    ],
    // ...
})
See Also