@witchcraft/spellcraft
    Preparing search index...
    • Creates the given keyboard layout, assiging the correct sizes and positions to keys.

      It returns an array of raw keys so that if you're extending Key you can create them with your extended class (you should override Key.create).

      Labels are assigned for most keys in english as a fallback, see labelWithEvent/labelWithKeyboardMap for proper labeling during runtime.

      Currently only supports generating the following layouts: ansi, iso. Technically the layout returned is a variation of these that includes half height 1.3333u (4u / 3 keys) media keys over the numpad.

      Pull requests for standard layouts welcomed.

      You can remove sections using the options. Note that this just removes them and does not do any repositioning. If you only remove the numpad, for example, the media keys will still be placed above it. The idea is to easily allow reducing the size of the created layout to then adjust only a few keys to your liking.

      Also note the navigation section is split into two sections with navigation only refering to the 6 Insert, Home, etc. keys, and arrowKeys refering to the arrow keys.

      This also adds the following classes to some keys: center-label for media and arrow keys, and iso-enter for the iso enter which requires a different approach to styling (see the demo, it's painful).

      Type Parameters

      • TNumpad extends boolean = true
      • TMediaKeys extends boolean = true
      • TFn extends boolean = true
      • TNavigation extends boolean = true
      • TArrowKeys extends boolean = true
      • TNames extends string =
            | "Escape"
            | (
                TFn extends true
                    ? | "F1"
                    | "F2"
                    | "F3"
                    | "F4"
                    | "F5"
                    | "F6"
                    | "F7"
                    | "F8"
                    | "F9"
                    | "F10"
                    | "F11"
                    | "F12"
                    : never
            )
            | "Backquote"
            | "Digit1"
            | "Digit2"
            | "Digit3"
            | "Digit4"
            | "Digit5"
            | "Digit6"
            | "Digit7"
            | "Digit8"
            | "Digit9"
            | "Digit0"
            | "Minus"
            | "Equal"
            | "Backspace"
            | "Tab"
            | "KeyQ"
            | "KeyW"
            | "KeyE"
            | "KeyR"
            | "KeyT"
            | "KeyY"
            | "KeyU"
            | "KeyI"
            | "KeyO"
            | "KeyP"
            | "BracketLeft"
            | "BracketRight"
            | "Backslash"
            | "CapsLock"
            | "KeyA"
            | "KeyS"
            | "KeyD"
            | "KeyF"
            | "KeyG"
            | "KeyH"
            | "KeyJ"
            | "KeyK"
            | "KeyL"
            | "Semicolon"
            | "Quote"
            | "Enter"
            | "VirtualShiftLeft"
            | "IntlBackslash"
            | "KeyZ"
            | "KeyX"
            | "KeyC"
            | "KeyV"
            | "KeyB"
            | "KeyN"
            | "KeyM"
            | "Comma"
            | "Period"
            | "Slash"
            | "VirtualShiftRight"
            | "VirtualControlLeft"
            | "VirtualMetaLeft"
            | "VirtualAltLeft"
            | "Space"
            | "VirtualAltRight"
            | "VirtualMetaRight"
            | "ContextMenu"
            | "VirtualControlRight"
            | "PrintScreen"
            | "ScrollLock"
            | "Pause"
            | (TNavigation extends true ? "Insert" | "Home" | "PageUp" : never)
            | (
                TArrowKeys extends true
                    ? "ArrowUp"
                    | "ArrowLeft"
                    | "ArrowDown"
                    | "ArrowRight"
                    : never
            )
            | (
                TMediaKeys extends true
                    ? | "AudioVolumeMute"
                    | "AudioVolumeDown"
                    | "AudioVolumeUp"
                    | "MediaTrackPrevious"
                    | "MediaTrackPause"
                    | "MediaTrackNext"
                    : never
            )
            | (
                TNumpad extends true
                    ? | "NumLock"
                    | "NumpadDivide"
                    | "NumpadMultiply"
                    | "NumpadSubtract"
                    | "Numpad7"
                    | "Numpad8"
                    | "Numpad9"
                    | "NumpadAdd"
                    | "Numpad4"
                    | "Numpad5"
                    | "Numpad6"
                    | "Numpad1"
                    | "Numpad2"
                    | "Numpad3"
                    | "NumpadEnter"
                    | "Numpad0"
                    | "NumpadDecimal"
                    : never
            )

      Parameters

      • type: "" | "ansi" | "iso" = "ansi"
      • __namedParameters: Partial<
            {
                arrowKeys: TArrowKeys;
                fn: TFn;
                mediaKeys: TMediaKeys;
                navigation: TNavigation;
                numpad: TNumpad;
            },
        > = {}

      Returns Mutable<Pick<Key<TNames>, "id"> & Partial<Omit<Key<TNames>, "id">>>[]