Namespace: Hotkeys

UI. Hotkeys

A class which contains hotkeys APIs.

You must NOT instantiate this yourself. Access instances of this class using instance.UI.hotkeys

Members


<static> Keys

Available hotkeys that can be passed to instance.UI.hotkeys.on or instance.UI.hotkeys.off.

Properties:
Name Type Description
CTRL_SHIFT_EQUAL string Rotate the document clockwise
COMMAND_SHIFT_EQUAL string Rotate the document clockwise
CTRL_SHIFT_MINUS string Rotate the document counterclockwise
COMMAND_SHIFT_MINUS string Rotate the document counterclockwise
CTRL_C string Copy selected text or annotations
COMMAND_C string Copy selected text or annotations
CTRL_V string Paste text or annotations
COMMAND_V string Paste text or annotations
CTRL_Z string Undo an annotation change
COMMAND_Z string Undo an annotation change
CTRL_Y string Redo an annotation change
COMMAND_SHIFT_Z string Redo an annotation change
CTRL_O string Open the file picker
COMMAND_O string Open the file picker
CTRL_F string Open the search overlay
COMMAND_F string Open the search overlay
CTRL_EQUAL string Zoom in
COMMAND_EQUAL string Zoom in
CTRL_MINUS string Zoom out
COMMAND_MINUS string Zoom out
CTRL_0 string Fit the document to the screen width in a small screen(< 640px), otherwise fit it to its original size
COMMAND_0 string Fit the document to the screen width in a small screen(< 640px), otherwise fit it to its original size
CTRL_P string Print
COMMAND_P string Print
CTRL_B string Quickly bookmark a page and open the bookmark panel
COMMAND_B string Quickly bookmark a page and open the bookmark panel
PAGE_UP string Go to the previous page
PAGE_DOWN string Go to the next page
UP string Go to the previous page in single layout mode (ArrowUp)
DOWN string Go to the next page in single layout mode (ArrowDown)
SPACE string Hold to switch to Pan mode and release to return to previous tool
ESCAPE string Select the AnnotationEdit tool
P string Select the Pan tool
A string Select the AnnotationCreateArrow tool
C string Select the AnnotationCreateCallout tool
E string Select the AnnotationEraser tool
F string Select the AnnotationCreateFreeHand tool
I string Select the AnnotationCreateStamp tool
L string Select the AnnotationCreateLine tool
N string Select the AnnotationCreateSticky tool
O string Select the AnnotationCreateEllipse tool
R string Select the AnnotationCreateRectangle tool
Q string Select the AnnotationCreateRubberStamp tool
T string Select the AnnotationCreateFreeText tool
S string Open the signature modal or the overlay
G string Select the AnnotationCreateTextSquiggly tool
H string Select the AnnotationCreateTextHighlight tool
K string Select the AnnotationCreateTextStrikeout tool
U string Select the AnnotationCreateTextUnderline tool

Methods


<static> off( [key] [, handler])

Remove an event handler for the given hotkey
Parameters:
Name Type Argument Description
key string | UI.Hotkeys.Keys <optional>
An optional keyboard key. If not passed, all handlers will be removed
handler function <optional>
An optional function. If not passed, all handlers of the given key will be removed
Example
WebViewer(...)
  .then(function(instance) {
      // this will remove all handlers for ctrl = and command =
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.CTRL_EQUAL);
      instance.UI.hotkeys.off(instance.UI.hotkeys.Keys.COMMAND_EQUAL);
  });

<static> on(key [, handler])

Add an event handler for the given hotkey
Parameters:
Name Type Argument Description
key string | UI.Hotkeys.Keys A keyboard key
If a hotkey is consisted of more than one key. Those keys should be connected using '+'.
handler function | object <optional>
An optional argument
If it is undefined, the default handler of the given key will be registered
If it is an function, it will be called on key down
If it is an object, it should have the shape of { keydown: func1, keyup: func2 }. Func1 will be called on keydown while func2 will be called on keyup
Example
WebViewer(...)
  .then(function(instance) {
    const { UI } = instance;
      // this will register the default zoom in handler
      UI.hotkeys.on(UI.hotkeys.Keys.CTRL_EQUAL);
      UI.hotkeys.on(UI.hotkeys.Keys.COMMAND_EQUAL);
       // this will be called on keydown
      UI.hotkeys.on('ctrl+d, command+d', e => {
        e.preventDefault();
        instance.Core.documentViewer.closeDocument();
      });
       UI.hotkeys.on('ctrl+g', {
        keydown: e => {
          console.log('ctrl+g is pressed!');
        },
        keyup: e => {
          console.log('ctrl+g is released!')
        },
      });
  });