fix: allow typing in search box without WASD moving camera
This commit is contained in:
parent
8916acbe4b
commit
76c96728f3
1 changed files with 6 additions and 0 deletions
|
|
@ -45,6 +45,12 @@ export function FacilityScene({
|
|||
|
||||
useEffect(() => {
|
||||
const handleDown = (e: KeyboardEvent) => {
|
||||
// Don't capture keys when an input/textarea is focused
|
||||
const activeEl = document.activeElement;
|
||||
if (activeEl && (activeEl.tagName === 'INPUT' || activeEl.tagName === 'TEXTAREA')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (['KeyW', 'KeyA', 'KeyS', 'KeyD', 'ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(e.code)) {
|
||||
e.preventDefault();
|
||||
setKeysPressed(k => ({ ...k, [e.code]: true }));
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue