Using React and noticed intercepting a KeyboardEvent seems broken on Brave (verified working on Safari, Chrome, DuckDuckGo)
The code is intended to toggle a state change when the CMD+K keys are pressed. On all other browsers this works, the state is toggled and the user can continue. On Brave, the state seems to be toggled and then untoggled immediately after. Any ideas? Attaching the code here:
const [open, setOpen] = useState(false);
useEffect(() => {
const down = (e: KeyboardEvent) => {
if (e.key === "k" && (e.metaKey || e.ctrlKey)) {
e.preventDefault();
setOpen((open) => !open);
}
}
document.addEventListener("keydown", down);
return () => document.removeEventListener("keydown", down)
}, []);