()
| 2 | import { Priority } from '@linen/types'; |
| 3 | |
| 4 | function usePriority() { |
| 5 | const [priority, setPriority] = useState(Priority.KEYBOARD); |
| 6 | useEffect(() => { |
| 7 | const onMouseAction = () => { |
| 8 | setPriority(Priority.MOUSE); |
| 9 | }; |
| 10 | const onKeyboardAction = () => { |
| 11 | setPriority(Priority.KEYBOARD); |
| 12 | }; |
| 13 | window.addEventListener('keyup', onKeyboardAction); |
| 14 | window.addEventListener('keydown', onKeyboardAction); |
| 15 | window.addEventListener('mousemove', onMouseAction); |
| 16 | return () => { |
| 17 | window.removeEventListener('keyup', onKeyboardAction); |
| 18 | window.removeEventListener('keydown', onKeyboardAction); |
| 19 | window.removeEventListener('mousemove', onMouseAction); |
| 20 | }; |
| 21 | }, []); |
| 22 | |
| 23 | return { priority }; |
| 24 | } |
| 25 | |
| 26 | export default usePriority; |
no outgoing calls
no test coverage detected