A class which contains hotkeys APIs.
⚠ You must NOT instantiate this yourself. Access instances of this class using instance.hotkeys
⚠ You must NOT instantiate this yourself. Access instances of this class using instance.hotkeys
Members
-
<static> AvailableHotkeys :string
-
Available hotkeys that can be passed to instance.hotkeys.on or instance.hotkeys.off as lowercase. Hotkeys that use the Ctrl key can also be activated by pressing the Command key.
⚠ These strings are not static properties of this class. They are listed here only for the documentation purpose.Type:
- string
Properties:
Name Type Description Ctrl_Shift_Equals
string Rotate the document clockwise (Ctrl+Shift+=). Ctrl_Shift_Minus
string Rotate the document counterclockwise (Ctrl+Shift+-) Ctrl_C
string Copy selected text or annotations Ctrl_V
string Paste text or annotations Ctrl_Z
string Undo an annotation change Ctrl_Y
string Redo an annotation change Ctrl_O
string Open the file picker Ctrl_F
string Open the search overlay Ctrl_Equals
string Zoom in (Ctrl+=) Ctrl_Minus
string Zoom out (Ctrl+-) Ctrl_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 PageUp
string Go to the previous page PageDown
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
-
off( [key] [, handler])
-
Remove an event handler for the given hotkey
Parameters:
Name Type Argument Description key
string <optional>
An optional keyboard key or a tool name. 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('ctrl+=, command+='); // this is equivalent to instance.hotkeys.off('escape'); instance.hotkeys.off('AnnotationEdit'); });
-
on(key [, handler])
-
Add an event handler for the given hotkey
Parameters:
Name Type Argument Description key
string A keyboard key or a tool name.
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 keyupExample
WebViewer(...) .then(function(instance) { // 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!') }, }); // this will register the default zoom in handler instance.hotkeys.on('ctrl+=, command+='); // this is equivalent to instance.hotkeys.on('escape'); instance.hotkeys.on('AnnotationEdit'); });