@@ -23,36 +23,40 @@ const BindingsWaiter = function (app, manager) {
2323 * @param {event } e
2424 */
2525BindingsWaiter . prototype . parseInput = function ( e ) {
26- let modKey = e . altKey ;
27- if ( this . app . options . useMetaKey ) modKey = e . metaKey ;
26+ const modKey = this . app . options . useMetaKey ? e . metaKey : e . altKey ;
27+
2828 if ( e . ctrlKey && modKey ) {
2929 let elem ;
3030 switch ( e . code ) {
31- case "KeyF" :
31+ case "KeyF" : // Focus search
3232 e . preventDefault ( ) ;
33- document . getElementById ( "search" ) . focus ( ) ; // Focus search
33+ document . getElementById ( "search" ) . focus ( ) ;
3434 break ;
35- case "KeyI" :
35+ case "KeyI" : // Focus input
3636 e . preventDefault ( ) ;
37- document . getElementById ( "input-text" ) . focus ( ) ; // Focus input
37+ document . getElementById ( "input-text" ) . focus ( ) ;
3838 break ;
39- case "KeyO" :
39+ case "KeyO" : // Focus output
4040 e . preventDefault ( ) ;
41- document . getElementById ( "output-text" ) . focus ( ) ; // Focus output
41+ document . getElementById ( "output-text" ) . focus ( ) ;
4242 break ;
43- case "Period" :
43+ case "Period" : // Focus next operation
44+ e . preventDefault ( ) ;
4445 try {
45- elem = document . activeElement . closest ( ".operation" ) ;
46+ elem = document . activeElement . closest ( ".operation" ) || document . querySelector ( "#rec-list .operation" ) ;
4647 if ( elem . parentNode . lastChild === elem ) {
47- elem . parentNode . firstChild . querySelectorAll ( ".arg" ) [ 0 ] . focus ( ) ; // if operation is last in recipe, loop around to the top operation's first argument
48+ // If operation is last in recipe, loop around to the top operation's first argument
49+ elem . parentNode . firstChild . querySelectorAll ( ".arg" ) [ 0 ] . focus ( ) ;
4850 } else {
49- elem . nextSibling . querySelectorAll ( ".arg" ) [ 0 ] . focus ( ) ; //focus first argument of next operation
51+ // Focus first argument of next operation
52+ elem . nextSibling . querySelectorAll ( ".arg" ) [ 0 ] . focus ( ) ;
5053 }
5154 } catch ( e ) {
5255 // do nothing, just don't throw an error
5356 }
5457 break ;
55- case "KeyB" :
58+ case "KeyB" : // Set breakpoint
59+ e . preventDefault ( ) ;
5660 try {
5761 elem = document . activeElement . closest ( ".operation" ) . querySelectorAll ( ".breakpoint" ) [ 0 ] ;
5862 if ( elem . getAttribute ( "break" ) === "false" ) {
@@ -67,7 +71,8 @@ BindingsWaiter.prototype.parseInput = function(e) {
6771 // do nothing, just don't throw an error
6872 }
6973 break ;
70- case "KeyD" :
74+ case "KeyD" : // Disable operation
75+ e . preventDefault ( ) ;
7176 try {
7277 elem = document . activeElement . closest ( ".operation" ) . querySelectorAll ( ".disable-icon" ) [ 0 ] ;
7378 if ( elem . getAttribute ( "disabled" ) === "false" ) {
@@ -85,29 +90,36 @@ BindingsWaiter.prototype.parseInput = function(e) {
8590 // do nothing, just don't throw an error
8691 }
8792 break ;
88- case "Space" :
89- this . app . bake ( ) ; // bake the recipe
93+ case "Space" : // Bake
94+ e . preventDefault ( ) ;
95+ this . app . bake ( ) ;
9096 break ;
91- case "Quote" :
92- this . app . bake ( true ) ; // step through the recipe
97+ case "Quote" : // Step through
98+ e . preventDefault ( ) ;
99+ this . app . bake ( true ) ;
93100 break ;
94- case "KeyC" :
95- this . manager . recipe . clearRecipe ( ) ; // clear recipe
101+ case "KeyC" : // Clear recipe
102+ e . preventDefault ( ) ;
103+ this . manager . recipe . clearRecipe ( ) ;
96104 break ;
97- case "KeyS" :
98- this . manager . output . saveClick ( ) ; // save output to file
105+ case "KeyS" : // Save output to file
106+ e . preventDefault ( ) ;
107+ this . manager . output . saveClick ( ) ;
99108 break ;
100- case "KeyL" :
101- this . manager . controls . loadClick ( ) ; // load a recipe
109+ case "KeyL" : // Load recipe
110+ e . preventDefault ( ) ;
111+ this . manager . controls . loadClick ( ) ;
102112 break ;
103- case "KeyM" :
104- this . manager . controls . switchClick ( ) ; // switch input & output
113+ case "KeyM" : // Switch input and output
114+ e . preventDefault ( ) ;
115+ this . manager . output . switchClick ( ) ;
105116 break ;
106117 default :
107- if ( e . code . match ( / D i g i t [ 0 - 9 ] / g) ) {
118+ if ( e . code . match ( / D i g i t [ 0 - 9 ] / g) ) { // Select nth operation
108119 e . preventDefault ( ) ;
109120 try {
110- document . querySelector ( `li:nth-child(${ e . code . substr ( - 1 ) } ) .arg` ) . focus ( ) ; // select the first argument of the operation corresponding to the number pressed
121+ // Select the first argument of the operation corresponding to the number pressed
122+ document . querySelector ( `li:nth-child(${ e . code . substr ( - 1 ) } ) .arg` ) . focus ( ) ;
111123 } catch ( e ) {
112124 // do nothing, just don't throw an error
113125 }
@@ -117,6 +129,7 @@ BindingsWaiter.prototype.parseInput = function(e) {
117129 }
118130} ;
119131
132+
120133/**
121134 * Updates keybinding list when metaKey option is toggled
122135 *
@@ -149,12 +162,12 @@ BindingsWaiter.prototype.updateKeybList = function() {
149162 <td>Ctrl+${ modMac } +o</td>
150163 </tr>
151164 <tr>
152- <td>Place cursor in first argument field<br> of the next operation in the recipe</td>
165+ <td>Place cursor in first argument field of the next operation in the recipe</td>
153166 <td>Ctrl+${ modWinLin } +.</td>
154167 <td>Ctrl+${ modMac } +.</td>
155168 </tr>
156169 <tr>
157- <td>Place cursor in first argument field<br> of the nth operation in the recipe</td>
170+ <td>Place cursor in first argument field of the nth operation in the recipe</td>
158171 <td>Ctrl+${ modWinLin } +[1-9]</td>
159172 <td>Ctrl+${ modMac } +[1-9]</td>
160173 </tr>
0 commit comments