ComPDFKit Web SDK
    Preparing search index...

    Function on

    • Binds keys. With a handler, the handler is called on keydown (a function) or on keydown and keyup ({ keydown, keyup }). Without a handler, the key gets its built-in shortcut back, for example Keys.CTRL_EQUAL zooms in. Without arguments, all shortcuts resume.

      Parameters

      • Optionalkey: string

        Keys such as ctrl+shift+=; separate several with commas.

      • Optionalhandler:
            | ((event: KeyboardEvent) => unknown)
            | {
                keydown?: (event: KeyboardEvent) => unknown;
                keyup?: (event: KeyboardEvent) => unknown;
            }

        The function or { keydown, keyup } object to call.

        • (event: KeyboardEvent) => unknown
        • {
              keydown?: (event: KeyboardEvent) => unknown;
              keyup?: (event: KeyboardEvent) => unknown;
          }
          • Optionalkeydown?: (event: KeyboardEvent) => unknown

            Called when the shortcut key is pressed.

          • Optionalkeyup?: (event: KeyboardEvent) => unknown

            Called when the shortcut key is released.

      Returns void

      // A custom shortcut
      instance.UI.hotkeys.on('ctrl+shift+d, command+shift+d', (event) => {
      event.preventDefault();
      instance.UI.downloadPdf();
      });
      // Give back a built-in shortcut that was turned off
      instance.UI.hotkeys.on(instance.UI.hotkeys.Keys.CTRL_EQUAL);