arch: move web folder into api & move api to top level
This commit is contained in:
19
frontend/src/shared/hooks/onEscapeKeyDown.ts
Normal file
19
frontend/src/shared/hooks/onEscapeKeyDown.ts
Normal file
@ -0,0 +1,19 @@
|
||||
import { useEffect } from 'react';
|
||||
import KeyCodes from 'shared/constants/keyCodes';
|
||||
|
||||
const useOnEscapeKeyDown = (isListening: boolean, onEscapeKeyDown: () => void) => {
|
||||
useEffect(() => {
|
||||
const handleKeyDown = (event: any) => {
|
||||
if (event.keyCode === KeyCodes.ESCAPE) {
|
||||
onEscapeKeyDown();
|
||||
}
|
||||
};
|
||||
if (isListening) {
|
||||
document.addEventListener('keydown', handleKeyDown);
|
||||
}
|
||||
return () => {
|
||||
document.removeEventListener('keydown', handleKeyDown);
|
||||
};
|
||||
}, [isListening, onEscapeKeyDown]);
|
||||
};
|
||||
export default useOnEscapeKeyDown;
|
Reference in New Issue
Block a user