UNPKG

@gechiui/components

Version:
41 lines (34 loc) 859 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.normalizeArrowKey = normalizeArrowKey; var _keycodes = require("@gechiui/keycodes"); /** * GeChiUI dependencies */ /** * @type {number[]} */ const arrowKeys = [_keycodes.RIGHT, _keycodes.UP, _keycodes.DOWN, _keycodes.LEFT]; /** * Normalizes the 'key' property of a KeyboardEvent in IE/Edge * * Source: * https://github.com/downshift-js/downshift/blob/a71005bd879d05d7dcb892d1e0dc5c6ca74e9d39/src/utils.js#L279 * * @param {import('react').KeyboardEvent} event A keyboardEvent object * * @return {string} The keyboard key */ function normalizeArrowKey(event) { const { key, keyCode } = event; if (arrowKeys.includes(keyCode) && key.indexOf('Arrow') !== 0) { return `Arrow${key}`; } return key; } //# sourceMappingURL=keyboard.js.map