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:
534 bytes
|
Rev | Line | |
---|
[d565449] | 1 | import useKeyPressDefault from './useKeyPress';
|
---|
| 2 | import useUpdateEffect from './useUpdateEffect';
|
---|
| 3 | var useKeyPressEvent = function (key, keydown, keyup, useKeyPress) {
|
---|
| 4 | if (useKeyPress === void 0) { useKeyPress = useKeyPressDefault; }
|
---|
| 5 | var _a = useKeyPress(key), pressed = _a[0], event = _a[1];
|
---|
| 6 | useUpdateEffect(function () {
|
---|
| 7 | if (!pressed && keyup) {
|
---|
| 8 | keyup(event);
|
---|
| 9 | }
|
---|
| 10 | else if (pressed && keydown) {
|
---|
| 11 | keydown(event);
|
---|
| 12 | }
|
---|
| 13 | }, [pressed]);
|
---|
| 14 | };
|
---|
| 15 | export default useKeyPressEvent;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.