Keyboard shortcut tweaks

This commit is contained in:
Aria Minaei 2021-09-01 10:51:50 +02:00
parent 5d37c15173
commit b3e4aca200

View file

@ -2,12 +2,17 @@ import {useEffect} from 'react'
import getStudio from '@theatre/studio/getStudio' import getStudio from '@theatre/studio/getStudio'
import {cmdIsDown} from '@theatre/studio/utils/keyboardUtils' import {cmdIsDown} from '@theatre/studio/utils/keyboardUtils'
import {getSelectedSequence} from '@theatre/studio/selectors' import {getSelectedSequence} from '@theatre/studio/selectors'
import type {$IntentionalAny} from '@theatre/shared/utils/types'
export default function useKeyboardShortcuts() { export default function useKeyboardShortcuts() {
const studio = getStudio() const studio = getStudio()
useEffect(() => { useEffect(() => {
const handleKeyDown = (e: KeyboardEvent) => { const handleKeyDown = (e: KeyboardEvent) => {
if (e.target && (e.target as HTMLElement).tagName === 'INPUT') { const target: null | HTMLElement = e.target as unknown as $IntentionalAny
if (
target &&
(target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')
) {
return return
} }
@ -18,6 +23,8 @@ export default function useKeyboardShortcuts() {
} else { } else {
studio.undo() studio.undo()
} }
} else {
return
} }
} else if ( } else if (
e.key === ' ' && e.key === ' ' &&
@ -33,6 +40,8 @@ export default function useKeyboardShortcuts() {
} else { } else {
seq.play() seq.play()
} }
} else {
return
} }
} else { } else {
return return