Namespace: Hotkeys

WebViewerInstance. Hotkeys

A class which contains hotkeys APIs.

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

Members


<static> Keys

Available hotkeys that can be passed to instance.hotkeys.on or instance.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
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 AnnotationEraserTool 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
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 | WebViewerInstance.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.hotkeys.off(instance.hotkeys.Keys.CTRL_EQUAL);
      instance.hotkeys.off(instance.hotkeys.Keys.COMMAND_EQUAL);
  });

<static> on(key [, handler])

Add an event handler for the given hotkey
Parameters:
Name Type Argument Description
key string | WebViewerInstance.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) {
      // this will register the default zoom in handler
      instance.hotkeys.on(instance.hotkeys.Keys.CTRL_EQUAL);
      instance.hotkeys.on(instance.hotkeys.Keys.COMMAND_EQUAL);
        // this will be called on keydown
      instance.hotkeys.on('ctrl+d, command+d', e => {
        e.preventDefault();
        instance.closeDocument();
      });
        instance.hotkeys.on('ctrl+g', {
        keydown: e => {
          console.log('ctrl+g is pressed!');
        },
        keyup: e => {
          console.log('ctrl+g is released!')
        },
      });
  });