fix(modal): trigger on keydown instead of keyup to prevent interference

This commit is contained in:
Paul Makles 2023-02-22 17:59:26 +01:00
parent 7d544c82ab
commit 122f047c85
No known key found for this signature in database
GPG key ID: 5059F398521BB0F6

View file

@ -9,7 +9,7 @@ export default observer(() => {
const history = useHistory();
useEffect(() => {
function keyUp(event: KeyboardEvent) {
function keyDown(event: KeyboardEvent) {
if (event.key === "Escape") {
modalController.pop("close");
} else if (event.key === "Enter") {
@ -18,8 +18,8 @@ export default observer(() => {
}
}
document.addEventListener("keyup", keyUp);
return () => document.removeEventListener("keyup", keyUp);
document.addEventListener("keydown", keyDown);
return () => document.removeEventListener("keydown", keyDown);
}, []);
return (