File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 5
5
* @requires core
6
6
*/
7
7
export function isCode ( input ) {
8
+ const leftRightKeys = [
9
+ 'AltLeft' , 'AltRight' ,
10
+ 'ShiftLeft' , 'ShiftRight' ,
11
+ 'ControlLeft' , 'ControlRight' ,
12
+ 'MetaLeft' , 'MetaRight' ,
13
+ ] ;
14
+ if ( leftRightKeys . includes ( input ) ) {
15
+ return false ;
16
+ }
8
17
if ( typeof input !== 'string' ) {
9
18
return false ;
10
19
}
@@ -913,6 +922,15 @@ function keyboard(p5, fn){
913
922
* </div>
914
923
*/
915
924
function isCode ( input ) {
925
+ const leftRightKeys = [
926
+ 'AltLeft' , 'AltRight' ,
927
+ 'ShiftLeft' , 'ShiftRight' ,
928
+ 'ControlLeft' , 'ControlRight' ,
929
+ 'MetaLeft' , 'MetaRight' ,
930
+ ] ;
931
+ if ( leftRightKeys . includes ( input ) ) {
932
+ return false ;
933
+ }
916
934
if ( typeof input !== 'string' ) {
917
935
return false ;
918
936
}
Original file line number Diff line number Diff line change @@ -189,6 +189,11 @@ suite('Keyboard Events', function() {
189
189
assert . isTrue ( isCode ( 'Control' ) ) ;
190
190
assert . isTrue ( isCode ( 'ab' ) ) ;
191
191
} ) ;
192
+
193
+ test ( 'returns false for strings for letright keys' , function ( ) {
194
+ assert . isFalse ( isCode ( 'AltLeft' ) ) ;
195
+ assert . isFalse ( isCode ( 'ShiftRight' ) ) ;
196
+ } ) ;
192
197
193
198
test ( 'handles edge cases correctly' , function ( ) {
194
199
assert . isFalse ( isCode ( '' ) ) ; // empty string
You can’t perform that action at this time.
0 commit comments