1 import type { DependencyList } from 'react';
2 import { useCallback, useEffect } from 'react';
4 const useKeyPress = (cb: (e: KeyboardEvent) => void, deps: DependencyList = [], el = document) => {
5 const callback = useCallback(cb, deps);
8 el.addEventListener('keydown', callback);
9 return () => el.removeEventListener('keydown', callback);
13 export default useKeyPress;