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> Keys
-
Available hotkeys that can be passed to instance.hotkeys.on or instance.hotkeys.off.
Properties:
Name Type Description CTRL_SHIFT_EQUALstring Rotate the document clockwise COMMAND_SHIFT_EQUALstring Rotate the document clockwise CTRL_SHIFT_MINUSstring Rotate the document counterclockwise COMMAND_SHIFT_MINUSstring Rotate the document counterclockwise CTRL_Cstring Copy selected text or annotations COMMAND_Cstring Copy selected text or annotations CTRL_Vstring Paste text or annotations COMMAND_Vstring Paste text or annotations CTRL_Zstring Undo an annotation change COMMAND_Zstring Undo an annotation change CTRL_Ystring Redo an annotation change COMMAND_SHIFT_Zstring Redo an annotation change CTRL_Ostring Open the file picker COMMAND_Ostring Open the file picker CTRL_Fstring Open the search overlay COMMAND_Fstring Open the search overlay CTRL_EQUALstring Zoom in COMMAND_EQUALstring Zoom in CTRL_MINUSstring Zoom out COMMAND_MINUSstring Zoom out CTRL_0string Fit the document to the screen width in a small screen(< 640px), otherwise fit it to its original size COMMAND_0string Fit the document to the screen width in a small screen(< 640px), otherwise fit it to its original size CTRL_Pstring Print COMMAND_Pstring Print PAGE_UPstring Go to the previous page PAGE_DOWNstring Go to the next page UPstring Go to the previous page in single layout mode (ArrowUp) DOWNstring Go to the next page in single layout mode (ArrowDown) SPACEstring Hold to switch to Pan mode and release to return to previous tool ESCAPEstring Select the AnnotationEdit tool Pstring Select the Pan tool Astring Select the AnnotationCreateArrow tool Cstring Select the AnnotationCreateCallout tool Estring Select the AnnotationEraserTool tool Fstring Select the AnnotationCreateFreeHand tool Istring Select the AnnotationCreateStamp tool Lstring Select the AnnotationCreateLine tool Nstring Select the AnnotationCreateSticky tool Ostring Select the AnnotationCreateEllipse tool Rstring Select the AnnotationCreateRectangle tool Tstring Select the AnnotationCreateFreeText tool Sstring Open the signature modal or the overlay Gstring Select the AnnotationCreateTextSquiggly tool Hstring Select the AnnotationCreateTextHighlight tool Kstring Select the AnnotationCreateTextStrikeout tool Ustring Select the AnnotationCreateTextUnderline tool
Methods
-
<static> off( [key] [, handler])
-
Remove an event handler for the given hotkey
Parameters:
Name Type Argument Description keystring | UI.Hotkeys.Keys <optional>
An optional keyboard key. If not passed, all handlers will be removed handlerfunction <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 keystring | UI.Hotkeys.Keys A keyboard key
If a hotkey is consisted of more than one key. Those keys should be connected using '+'.handlerfunction | 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 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!') }, }); });