feat: publish HoloLake model-native living system source
This commit is contained in:
parent
6ad10edde1
commit
c395dd3a99
2467 changed files with 615073 additions and 0 deletions
20
product-source/hololake-platform/src/hooks/useAppKeyboard.ts
Normal file
20
product-source/hololake-platform/src/hooks/useAppKeyboard.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useEffect, useEffectEvent } from 'react'
|
||||
import { handleAppKeyboardEvent } from './appKeyboardShortcuts'
|
||||
import type { KeyboardActions } from './appKeyboardShortcuts'
|
||||
|
||||
export type { KeyboardActions } from './appKeyboardShortcuts'
|
||||
|
||||
export function useAppKeyboard(actions: KeyboardActions) {
|
||||
const onKeyDown = useEffectEvent((event: KeyboardEvent) => {
|
||||
handleAppKeyboardEvent(actions, event)
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
const handleWindowKeyDown = (event: KeyboardEvent) => {
|
||||
onKeyDown(event)
|
||||
}
|
||||
|
||||
window.addEventListener('keydown', handleWindowKeyDown, true)
|
||||
return () => window.removeEventListener('keydown', handleWindowKeyDown, true)
|
||||
}, [])
|
||||
}
|
||||
Loading…
Reference in a new issue