How can I add a keyboard shortcut to open the Settings app in OrbitOS? #33
-
How can I add a keyboard shortcut to open the Settings app in OrbitOS? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
To add a keyboard shortcut (e.g., Ctrl+S) for the Settings app: |
Beta Was this translation helpful? Give feedback.
To add a keyboard shortcut (e.g., Ctrl+S) for the Settings app:
1. Open
src/components/Desktop.js
.2. Add an event listener for keydown events using
useEffect
:javascript<br>import { useEffect } from 'react';<br>import { useAppContext } from '@/context/AppContext';<br>const Desktop = () => {<br> const { openApp } = useAppContext();<br> useEffect(() => {<br> const handleKeydown = (e) => {<br> if (e.ctrlKey && e.key === 's') openApp('settings');<br> };<br> window.addEventListener('keydown', handleKeydown);<br> return () => window.removeEventListener('keydown', handleKeydown);<br> }, [openApp]);<br> // ... rest of component<br>};<br>
3. Test with
npm run dev
by pressing Ctrl+S.4. Update tests in
t…