import { useMemo } from 'react';
import { useGlobal } from '../renderEnvironment/index.js';
import { isKeyArrow, isKeyTab } from './keyboard/identifiers.js';
var KeyListener = /** @class */ (function () {
    function KeyListener(globalObject) {
        var _this = this;
        var _a, _b;
        this.isTabPressed = false;
        this.isArrowPressed = false;
        (_a = globalObject.addEventListener) === null || _a === void 0 ? void 0 : _a.call(globalObject, 'keydown', function (e) {
            _this.isTabPressed = isKeyTab(e);
            _this.isArrowPressed = isKeyArrow(e);
        });
        (_b = globalObject.addEventListener) === null || _b === void 0 ? void 0 : _b.call(globalObject, 'mousedown', function () {
            _this.isTabPressed = false;
            _this.isArrowPressed = false;
        });
    }
    return KeyListener;
}());
export { KeyListener };
export function useKeyListener() {
    var globalObject = useGlobal();
    return useMemo(function () { return new KeyListener(globalObject); }, [globalObject]);
}
//# sourceMappingURL=keyListener.js.map