Class default

This is the main class of the library. It contains all the methods to check if a key event matches a key or a combination of keys.

Hierarchy

  • default

Constructors

  • Creates a new instance of the KeysKey class.

    Parameters

    • Optional enableDebugMode: boolean = false

      Whether to enable debug mode. When debug mode is enabled, additional console logs will be displayed. This may result in some performance issues. It's recommended to disable debug mode in a production environment.

    Returns default

Properties

AllKeys: {
    A: "A";
    Alt: "Alt";
    Ampersand: "&";
    ArrowDown: "ArrowDown";
    ArrowLeft: "ArrowLeft";
    ArrowRight: "ArrowRight";
    ArrowUp: "ArrowUp";
    Asterisk: "*";
    At: "@";
    AudioVolumeDown: "AudioVolumeDown";
    AudioVolumeMute: "AudioVolumeMute";
    AudioVolumeUp: "AudioVolumeUp";
    B: "B";
    Backquote: "`";
    Backslash: "\\";
    Backspace: "Backspace";
    BracketLeft: "[";
    BracketRight: "]";
    C: "C";
    CapsLock: "CapsLock";
    Caret: "^";
    Colon: ":";
    Comma: ",";
    Control: "Control";
    CurlyLeft: "{";
    CurlyRight: "}";
    D: "D";
    Delete: "Delete";
    Dollar: "$";
    E: "E";
    Eight: "8";
    End: "End";
    Enter: "Enter";
    Equal: "=";
    Escape: "Escape";
    Exclamation: "!";
    F: "F";
    Five: "5";
    Four: "4";
    G: "G";
    GreaterThan: ">";
    H: "H";
    Hash: "#";
    Home: "Home";
    I: "I";
    Insert: "Insert";
    J: "J";
    K: "K";
    L: "L";
    LessThan: "<";
    M: "M";
    MediaPlayPause: "MediaPlayPause";
    MediaStop: "MediaStop";
    MediaTrackNext: "MediaTrackNext";
    MediaTrackPrevious: "MediaTrackPrevious";
    Meta: "Meta";
    N: "N";
    Nine: "9";
    NumLock: "NumLock";
    O: "O";
    One: "1";
    Option: "Option";
    P: "P";
    PageDown: "PageDown";
    PageUp: "PageUp";
    ParenLeft: "(";
    ParenRight: ")";
    Percent: "%";
    Period: ".";
    Pipe: "|";
    Plus: "+";
    Q: "Q";
    QuestionMark: "?";
    Quote: "'";
    R: "R";
    S: "S";
    ScrollLock: "ScrollLock";
    Semicolon: ";";
    Seven: "7";
    Shift: "Shift";
    Six: "6";
    Slash: "/";
    Space: " ";
    Subtract: "-";
    T: "T";
    Tab: "Tab";
    Three: "3";
    Tilde: "~";
    Two: "2";
    U: "U";
    Underscore: "_";
    V: "V";
    W: "W";
    X: "X";
    Y: "Y";
    Z: "Z";
    Zero: "0";
    a: "a";
    b: "b";
    c: "c";
    d: "d";
    e: "e";
    f: "f";
    g: "g";
    h: "h";
    i: "i";
    j: "j";
    k: "k";
    l: "l";
    m: "m";
    n: "n";
    o: "o";
    p: "p";
    q: "q";
    r: "r";
    s: "s";
    t: "t";
    u: "u";
    v: "v";
    w: "w";
    x: "x";
    y: "y";
    z: "z";
    prototype: Function;
} = AllKeysGroup

Type declaration

  • A: "A"
  • Alt: "Alt"
  • Ampersand: "&"
  • ArrowDown: "ArrowDown"
  • ArrowLeft: "ArrowLeft"
  • ArrowRight: "ArrowRight"
  • ArrowUp: "ArrowUp"
  • Asterisk: "*"
  • At: "@"
  • AudioVolumeDown: "AudioVolumeDown"
  • AudioVolumeMute: "AudioVolumeMute"
  • AudioVolumeUp: "AudioVolumeUp"
  • B: "B"
  • Backquote: "`"
  • Backslash: "\\"
  • Backspace: "Backspace"
  • BracketLeft: "["
  • BracketRight: "]"
  • C: "C"
  • CapsLock: "CapsLock"
  • Caret: "^"
  • Colon: ":"
  • Comma: ","
  • Control: "Control"
  • CurlyLeft: "{"
  • CurlyRight: "}"
  • D: "D"
  • Delete: "Delete"
  • Dollar: "$"
  • E: "E"
  • Eight: "8"
  • End: "End"
  • Enter: "Enter"
  • Equal: "="
  • Escape: "Escape"
  • Exclamation: "!"
  • F: "F"
  • Five: "5"
  • Four: "4"
  • G: "G"
  • GreaterThan: ">"
  • H: "H"
  • Hash: "#"
  • Home: "Home"
  • I: "I"
  • Insert: "Insert"
  • J: "J"
  • K: "K"
  • L: "L"
  • LessThan: "<"
  • M: "M"
  • MediaPlayPause: "MediaPlayPause"
  • MediaStop: "MediaStop"
  • MediaTrackNext: "MediaTrackNext"
  • MediaTrackPrevious: "MediaTrackPrevious"
  • Meta: "Meta"
  • N: "N"
  • Nine: "9"
  • NumLock: "NumLock"
  • O: "O"
  • One: "1"
  • Option: "Option"
  • P: "P"
  • PageDown: "PageDown"
  • PageUp: "PageUp"
  • ParenLeft: "("
  • ParenRight: ")"
  • Percent: "%"
  • Period: "."
  • Pipe: "|"
  • Plus: "+"
  • Q: "Q"
  • QuestionMark: "?"
  • Quote: "'"
  • R: "R"
  • S: "S"
  • ScrollLock: "ScrollLock"
  • Semicolon: ";"
  • Seven: "7"
  • Shift: "Shift"
  • Six: "6"
  • Slash: "/"
  • Space: " "
  • Subtract: "-"
  • T: "T"
  • Tab: "Tab"
  • Three: "3"
  • Tilde: "~"
  • Two: "2"
  • U: "U"
  • Underscore: "_"
  • V: "V"
  • W: "W"
  • X: "X"
  • Y: "Y"
  • Z: "Z"
  • Zero: "0"
  • a: "a"
  • b: "b"
  • c: "c"
  • d: "d"
  • e: "e"
  • f: "f"
  • g: "g"
  • h: "h"
  • i: "i"
  • j: "j"
  • k: "k"
  • l: "l"
  • m: "m"
  • n: "n"
  • o: "o"
  • p: "p"
  • q: "q"
  • r: "r"
  • s: "s"
  • t: "t"
  • u: "u"
  • v: "v"
  • w: "w"
  • x: "x"
  • y: "y"
  • z: "z"
  • Readonly prototype: Function
Editing: typeof Editing = Editing
FunctionKeys: typeof FunctionKeys = FunctionKeys
Letter: typeof Letter = Letter
Lock: typeof Lock = Lock
Modifier: typeof Modifier = Modifier
Multimedia: typeof Multimedia = Multimedia
Navigation: typeof Navigation = Navigation
Number: typeof Number = Number
SpecialCharacter: typeof SpecialCharacter = SpecialCharacter
SpecialCombos: {
    isAltAndControl: ((event) => ("Alt" | "Control")[]);
    isAltAndShift: ((event) => ("Alt" | "Shift")[]);
    isAltOrControl: ((event) => ("Alt" | "Control")[]);
    isAltOrShift: ((event) => ("Alt" | "Shift")[]);
    isControlAndShift: ((event) => ("Control" | "Shift")[]);
    isControlOrShift: ((event) => ("Control" | "Shift")[]);
    isDigit: ((event) => default[]);
    isFunctionKey: ((event) => string[]);
    isLetter: ((event) => string[]);
    isLowercaseLetter: ((event) => string[]);
    isMediaControl: ((event) => string[]);
    isMetaAndControl: ((event) => ("Control" | "Meta")[]);
    isMetaAndShift: ((event) => ("Shift" | "Meta")[]);
    isMetaOrControl: ((event) => ("Control" | "Meta")[]);
    isMetaOrShift: ((event) => ("Shift" | "Meta")[]);
    isModifier: ((event) => any[]);
    isNavigationKey: ((event) => string[]);
    isNonEnglishLetter: ((event) => string[]);
    isSpecialCharacter: ((event) => string[]);
    isUppercaseLetter: ((event) => string[]);
    isWhitespace: ((event) => string[]);
} = SpecialCombos

Type declaration

  • isAltAndControl: ((event) => ("Alt" | "Control")[])
      • (event): ("Alt" | "Control")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Alt" | "Control")[]

  • isAltAndShift: ((event) => ("Alt" | "Shift")[])
      • (event): ("Alt" | "Shift")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Alt" | "Shift")[]

  • isAltOrControl: ((event) => ("Alt" | "Control")[])
      • (event): ("Alt" | "Control")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Alt" | "Control")[]

  • isAltOrShift: ((event) => ("Alt" | "Shift")[])
      • (event): ("Alt" | "Shift")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Alt" | "Shift")[]

  • isControlAndShift: ((event) => ("Control" | "Shift")[])
      • (event): ("Control" | "Shift")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Control" | "Shift")[]

  • isControlOrShift: ((event) => ("Control" | "Shift")[])
      • (event): ("Control" | "Shift")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Control" | "Shift")[]

  • isDigit: ((event) => default[])
  • isFunctionKey: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isLetter: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isLowercaseLetter: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isMediaControl: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isMetaAndControl: ((event) => ("Control" | "Meta")[])
      • (event): ("Control" | "Meta")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Control" | "Meta")[]

  • isMetaAndShift: ((event) => ("Shift" | "Meta")[])
      • (event): ("Shift" | "Meta")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Shift" | "Meta")[]

  • isMetaOrControl: ((event) => ("Control" | "Meta")[])
      • (event): ("Control" | "Meta")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Control" | "Meta")[]

  • isMetaOrShift: ((event) => ("Shift" | "Meta")[])
      • (event): ("Shift" | "Meta")[]
      • Parameters

        • event: KeyboardEvent

        Returns ("Shift" | "Meta")[]

  • isModifier: ((event) => any[])
      • (event): any[]
      • Parameters

        Returns any[]

  • isNavigationKey: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isNonEnglishLetter: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isSpecialCharacter: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isUppercaseLetter: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

  • isWhitespace: ((event) => string[])
      • (event): string[]
      • Parameters

        Returns string[]

SpecialKeysGroup: {
    Alt: "Alt";
    Ampersand: "&";
    ArrowDown: "ArrowDown";
    ArrowLeft: "ArrowLeft";
    ArrowRight: "ArrowRight";
    ArrowUp: "ArrowUp";
    Asterisk: "*";
    At: "@";
    AudioVolumeDown: "AudioVolumeDown";
    AudioVolumeMute: "AudioVolumeMute";
    AudioVolumeUp: "AudioVolumeUp";
    Backquote: "`";
    Backslash: "\\";
    Backspace: "Backspace";
    BracketLeft: "[";
    BracketRight: "]";
    CapsLock: "CapsLock";
    Caret: "^";
    Colon: ":";
    Comma: ",";
    Control: "Control";
    CurlyLeft: "{";
    CurlyRight: "}";
    Delete: "Delete";
    Dollar: "$";
    End: "End";
    Enter: "Enter";
    Equal: "=";
    Escape: "Escape";
    Exclamation: "!";
    GreaterThan: ">";
    Hash: "#";
    Home: "Home";
    Insert: "Insert";
    LessThan: "<";
    MediaPlayPause: "MediaPlayPause";
    MediaStop: "MediaStop";
    MediaTrackNext: "MediaTrackNext";
    MediaTrackPrevious: "MediaTrackPrevious";
    Meta: "Meta";
    NumLock: "NumLock";
    Option: "Option";
    PageDown: "PageDown";
    PageUp: "PageUp";
    ParenLeft: "(";
    ParenRight: ")";
    Percent: "%";
    Period: ".";
    Pipe: "|";
    Plus: "+";
    QuestionMark: "?";
    Quote: "'";
    ScrollLock: "ScrollLock";
    Semicolon: ";";
    Shift: "Shift";
    Slash: "/";
    Space: " ";
    Subtract: "-";
    Tab: "Tab";
    Tilde: "~";
    Underscore: "_";
    prototype: Function;
} = SpecialKeysGroup

Type declaration

  • Alt: "Alt"
  • Ampersand: "&"
  • ArrowDown: "ArrowDown"
  • ArrowLeft: "ArrowLeft"
  • ArrowRight: "ArrowRight"
  • ArrowUp: "ArrowUp"
  • Asterisk: "*"
  • At: "@"
  • AudioVolumeDown: "AudioVolumeDown"
  • AudioVolumeMute: "AudioVolumeMute"
  • AudioVolumeUp: "AudioVolumeUp"
  • Backquote: "`"
  • Backslash: "\\"
  • Backspace: "Backspace"
  • BracketLeft: "["
  • BracketRight: "]"
  • CapsLock: "CapsLock"
  • Caret: "^"
  • Colon: ":"
  • Comma: ","
  • Control: "Control"
  • CurlyLeft: "{"
  • CurlyRight: "}"
  • Delete: "Delete"
  • Dollar: "$"
  • End: "End"
  • Enter: "Enter"
  • Equal: "="
  • Escape: "Escape"
  • Exclamation: "!"
  • GreaterThan: ">"
  • Hash: "#"
  • Home: "Home"
  • Insert: "Insert"
  • LessThan: "<"
  • MediaPlayPause: "MediaPlayPause"
  • MediaStop: "MediaStop"
  • MediaTrackNext: "MediaTrackNext"
  • MediaTrackPrevious: "MediaTrackPrevious"
  • Meta: "Meta"
  • NumLock: "NumLock"
  • Option: "Option"
  • PageDown: "PageDown"
  • PageUp: "PageUp"
  • ParenLeft: "("
  • ParenRight: ")"
  • Percent: "%"
  • Period: "."
  • Pipe: "|"
  • Plus: "+"
  • QuestionMark: "?"
  • Quote: "'"
  • ScrollLock: "ScrollLock"
  • Semicolon: ";"
  • Shift: "Shift"
  • Slash: "/"
  • Space: " "
  • Subtract: "-"
  • Tab: "Tab"
  • Tilde: "~"
  • Underscore: "_"
  • Readonly prototype: Function
WhiteSpace: typeof WhiteSpace = WhiteSpace
debugMode: boolean = false
optimizedAndMode: boolean = false

Methods

  • Checks if all the keys match the provided event.

    Parameters

    • event: KeyEventEnum

      The DOM event that was triggered.

    • Rest ...keys: default[]

      A list of keys to check against the event. Can be provided as an array, KeysKeys groups (And / Or) or just lose arguments (will be interpreted as And).

    Returns default[]

    • Returns an array of keys that matched the event. If no key matched, returns undefined.
  • Checks if keys match the provided event. Basically just a wrapper for the .And method but it's a more intuitive name when checking for a single key.

    Parameters

    • event: KeyEventEnum

      The DOM event that was triggered.

    • Rest ...keys: default[]

      A list of keys to check against the event. Can be provided as an array, KeysKeys groups (And / Or) or just lose arguments (will be interpreted as And).

    Returns default[]

    • Returns an array of keys that matched the event. If no key matched, returns undefined.
  • Checks if keys match the provided event. If one key doesn't match it immediately terminates and does nto provide a full list of matches. This is faster than the And method.

    Parameters

    • event: KeyEventEnum

      The DOM event that was triggered.

    • Rest ...keys: default[]

      A list of keys to check against the event. Can be provided as an array, KeysKeys groups (And / Or) or just lose arguments (will be interpreted as And).

    Returns default[]

    • Returns an array of keys that matched the event. Returns undefined immediately if one key doesn't match.
  • Checks if one of the keys matches the provided event.

    Parameters

    • event: KeyEventEnum

      The DOM event that was triggered.

    • Rest ...keys: default[]

      A list of keys to check against the event. Can be provided as an array, KeysKeys groups (And / Or) or just lose arguments (will be interpreted as And).

    Returns default[]

    • Returns an array of keys that matched the event. If no key matched, returns undefined.

Generated using TypeDoc