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_Equalsstring Rotate the document clockwise (Ctrl+Shift+=). Ctrl_Shift_Minusstring Rotate the document counterclockwise (Ctrl+Shift+-) Ctrl_Cstring Copy selected text or annotations Ctrl_Vstring Paste text or annotations Ctrl_Zstring Undo an annotation change Ctrl_Ystring Redo an annotation change Ctrl_Ostring Open the file picker Ctrl_Fstring Open the search overlay Ctrl_Equalsstring Zoom in (Ctrl+=) Ctrl_Minusstring Zoom out (Ctrl+-) Ctrl_0string Fit the document to the screen width in a small screen(< 640px), otherwise fit it to its original size Ctrl_Pstring Print PageUpstring Go to the previous page PageDownstring 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
-
off( [key] [, handler])
-
Remove an event handler for the given hotkey
Parameters:
Name Type Argument Description keystring <optional>
An optional keyboard key or a tool name. 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('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 keystring A keyboard key or a tool name.
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 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'); });