@@ -42,27 +42,29 @@ export default (editor: Editor, opts = {}): void => {
42
42
} )
43
43
}
44
44
45
- let longPressTimeout : NodeJS . Timeout | undefined = undefined
45
+ if ( options . longPressDuration && options . longPressKey ) {
46
+ let longPressTimeout : NodeJS . Timeout | undefined = undefined
46
47
47
- document . addEventListener ( 'keydown' , event => {
48
- // Handle long press of the longPressKey
49
- if ( event . key . toLowerCase ( ) === options . longPressKey ) {
50
- if ( ! longPressTimeout ) {
51
- longPressTimeout = setTimeout ( ( ) => {
52
- editor . runCommand ( cmdKeymapsDialog )
53
- } , options . longPressDuration )
48
+ document . addEventListener ( 'keydown' , event => {
49
+ // Handle long press of the longPressKey
50
+ if ( event . key . toLowerCase ( ) === options . longPressKey ) {
51
+ if ( ! longPressTimeout ) {
52
+ longPressTimeout = setTimeout ( ( ) => {
53
+ editor . runCommand ( cmdKeymapsDialog )
54
+ } , options . longPressDuration )
55
+ }
54
56
}
55
- }
56
- } )
57
+ } )
57
58
58
- document . addEventListener ( 'keyup' , event => {
59
- // Clear the long press timeout if the key is released (and close the dialog)
60
- if ( event . key . toLowerCase ( ) === options . longPressKey && ! isShortcutActive ) {
61
- if ( longPressTimeout ) {
62
- clearTimeout ( longPressTimeout )
63
- longPressTimeout = undefined
59
+ document . addEventListener ( 'keyup' , event => {
60
+ // Clear the long press timeout if the key is released (and close the dialog)
61
+ if ( event . key . toLowerCase ( ) === options . longPressKey && ! isShortcutActive ) {
62
+ if ( longPressTimeout ) {
63
+ clearTimeout ( longPressTimeout )
64
+ longPressTimeout = undefined
65
+ }
66
+ editor . stopCommand ( cmdKeymapsDialog )
64
67
}
65
- editor . stopCommand ( cmdKeymapsDialog )
66
- }
67
- } )
68
+ } )
69
+ }
68
70
}
0 commit comments