@esri/calcite-components
Version:
Web Components for Esri's Calcite Design System.
25 lines (23 loc) • 523 B
JavaScript
/**
* Standardize key property of keyboard event (mostly for ie11)
*/
function getKey(key, dir) {
const lookup = {
Up: "ArrowUp",
Down: "ArrowDown",
Left: "ArrowLeft",
Right: "ArrowRight",
Spacebar: " ",
Esc: "Escape"
};
const adjustedKey = lookup[key] || key;
const isRTL = dir === "rtl";
if (isRTL && adjustedKey === "ArrowLeft") {
return "ArrowRight";
}
if (isRTL && adjustedKey === "ArrowRight") {
return "ArrowLeft";
}
return adjustedKey;
}
export { getKey as g };