/**
* DevExtreme (ui.grid_core.accessibility.js)
* Version: 22.1.7 (build 23032-0308)
* Build date: Wed Feb 01 2023
*
* Copyright (c) 2012 - 2023 Developer Express Inc. ALL RIGHTS RESERVED
* Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
*/
import * as accessibility from '../../ui/shared/accessibility';

export const registerKeyboardAction = function(viewName, instance, $element, selector, action) {
    const keyboardController = instance.getController('keyboardNavigation');
    if(instance.option('useLegacyKeyboardNavigation') || (keyboardController && !keyboardController.isKeyboardEnabled())) {
        return;
    }

    const executeKeyDown = args => {
        instance.executeAction('onKeyDown', args);
    };

    instance.createAction('onKeyDown');

    accessibility.registerKeyboardAction(viewName, instance, $element, selector, action, executeKeyDown);
};
