"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useKeyPress = void 0;
const react_1 = require("react");
const useKeyPress = (targetKey) => {
    const [keyPressed, setKeyPressed] = (0, react_1.useState)(false);
    (0, react_1.useEffect)(() => {
        const handleKeyDown = ({ key }) => {
            if (key === targetKey) {
                setKeyPressed(true);
            }
        };
        const handleKeyUp = ({ key }) => {
            if (key === targetKey) {
                setKeyPressed(false);
            }
        };
        window.addEventListener("keydown", handleKeyDown);
        window.addEventListener("keyup", handleKeyUp);
        return () => {
            window.removeEventListener("keydown", handleKeyDown);
            window.removeEventListener("keyup", handleKeyUp);
        };
    }, [targetKey]);
    return keyPressed;
};
exports.useKeyPress = useKeyPress;
//# sourceMappingURL=useKeyPress.js.map