@neovici/cosmoz-treenode-navigator
Version:
A Pion component that lets you navigate and search through hierarchically structured data-nodes and select one of them.
16 lines • 487 B
JavaScript
import { useEffect } from '@pionjs/pion';
export const useKeyDown = (key, callback) => {
const onKeyDown = (e) => {
if (e.key === key && callback instanceof Function) {
e.preventDefault();
return callback();
}
};
useEffect(() => {
document.addEventListener('keydown', onKeyDown);
return () => {
document.removeEventListener('keydown', onKeyDown);
};
});
};
//# sourceMappingURL=useKeyDown.js.map