export var keys = {};

export const KeyCode = {
    Escape: "Escape",
    F1: "F1",
    F2: "F2",
    F3: "F3",
    F4: "F4",
    F5: "F5",
    F6: "F6",
    F7: "F7",
    F8: "F8",
    F9: "F9",
    F10: "F10",
    F11: "F11",
    F12: "F12",
    Backquote: "Backquote",
    Digit1: "Digit1",
    Digit2: "Digit2",
    Digit3: "Digit3",
    Digit4: "Digit4",
    Digit5: "Digit5",
    Digit6: "Digit6",
    Digit7: "Digit7",
    Digit8: "Digit8",
    Digit9: "Digit9",
    Digit0: "Digit0",
    Minus: "Minus",
    Equal: "Equal",
    Backspace: "Backspace",
    Tab: "Tab",
    KeyQ: "KeyQ",
    KeyW: "KeyW",
    KeyE: "KeyE",
    KeyR: "KeyR",
    KeyT: "KeyT",
    KeyY: "KeyY",
    KeyU: "KeyU",
    KeyI: "KeyI",
    KeyO: "KeyO",
    KeyP: "KeyP",
    BracketLeft: "BracketLeft",
    BracketRight: "BracketRight",
    Backslash: "Backslash",
    CapsLock: "CapsLock",
    KeyA: "KeyA",
    KeyS: "KeyS",
    KeyD: "KeyD",
    KeyF: "KeyF",
    KeyG: "KeyG",
    KeyH: "KeyH",
    KeyJ: "KeyJ",
    KeyK: "KeyK",
    KeyL: "KeyL",
    Semicolon: "Semicolon",
    Quote: "Quote",
    Enter: "Enter",
    ShiftLeft: "ShiftLeft",
    KeyZ: "KeyZ",
    KeyX: "KeyX",
    KeyC: "KeyC",
    KeyV: "KeyV",
    KeyB: "KeyB",
    KeyN: "KeyN",
    KeyM: "KeyM",
    Comma: "Comma",
    Period: "Period",
    Slash: "Slash",
    ShiftRight: "ShiftRight",
    ControlLeft: "ControlLeft",
    AltLeft: "AltLeft",
    MetaLeft: "MetaLeft",
    Space: "Space",
    MetaRight: "MetaRight",
    AltRight: "AltRight",
    ArrowLeft: "ArrowLeft",
    ArrowUp: "ArrowUp",
    ArrowDown: "ArrowDown",
    ArrowRight: "ArrowRight",
};

window.addEventListener("keydown", onKeyDown);
window.addEventListener("keyup", onKeyUp);
function onKeyDown(event) {
    keys[event.code] = true;
}

function onKeyUp(event) {
    delete keys[event.code];
}
