main
Last change
on this file was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
426 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import { useState } from 'react';
|
---|
| 2 | import useKey from './useKey';
|
---|
| 3 | var useKeyPress = function (keyFilter) {
|
---|
| 4 | var _a = useState([false, null]), state = _a[0], set = _a[1];
|
---|
| 5 | useKey(keyFilter, function (event) { return set([true, event]); }, { event: 'keydown' }, [state]);
|
---|
| 6 | useKey(keyFilter, function (event) { return set([false, event]); }, { event: 'keyup' }, [state]);
|
---|
| 7 | return state;
|
---|
| 8 | };
|
---|
| 9 | export default useKeyPress;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.