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:
712 bytes
|
Rev | Line | |
---|
[d565449] | 1 | "use strict";
|
---|
| 2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
| 3 | var tslib_1 = require("tslib");
|
---|
| 4 | var useKeyPress_1 = tslib_1.__importDefault(require("./useKeyPress"));
|
---|
| 5 | var useUpdateEffect_1 = tslib_1.__importDefault(require("./useUpdateEffect"));
|
---|
| 6 | var useKeyPressEvent = function (key, keydown, keyup, useKeyPress) {
|
---|
| 7 | if (useKeyPress === void 0) { useKeyPress = useKeyPress_1.default; }
|
---|
| 8 | var _a = useKeyPress(key), pressed = _a[0], event = _a[1];
|
---|
| 9 | useUpdateEffect_1.default(function () {
|
---|
| 10 | if (!pressed && keyup) {
|
---|
| 11 | keyup(event);
|
---|
| 12 | }
|
---|
| 13 | else if (pressed && keydown) {
|
---|
| 14 | keydown(event);
|
---|
| 15 | }
|
---|
| 16 | }, [pressed]);
|
---|
| 17 | };
|
---|
| 18 | exports.default = useKeyPressEvent;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.