@kiwicom/orbit-components
Version:
Orbit-components is a React component library which provides developers with the easiest possible way of building Kiwi.com's products.
23 lines (22 loc) • 440 B
JavaScript
;
exports.__esModule = true;
exports.default = void 0;
const handleKeyDown = (onAction, action) => ev => {
if (ev.code === "Enter") {
if (onAction) {
onAction(ev);
}
if (action) {
action(ev);
}
} else if (ev.code === "Space") {
ev.preventDefault();
if (onAction) {
onAction(ev);
}
if (action) {
action(ev);
}
}
};
var _default = exports.default = handleKeyDown;