File tree Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Expand file tree Collapse file tree 2 files changed +6
-11
lines changed Original file line number Diff line number Diff line change @@ -8,11 +8,6 @@ export function isCode(input) {
8
8
if ( typeof input !== 'string' ) {
9
9
return false ;
10
10
}
11
-
12
- if ( input . length === 1 && / [ 0 - 9 ] / . test ( input ) ) {
13
- return true ;
14
- }
15
-
16
11
return input . length > 1 ;
17
12
}
18
13
function keyboard ( p5 , fn ) {
@@ -636,8 +631,10 @@ function keyboard(p5, fn){
636
631
this . code = null ;
637
632
} else {
638
633
// If other keys are still pressed, update code to the last pressed key
634
+ const lastPressedCode = Object . keys ( this . _downKeyCodes ) . pop ( ) ;
635
+ this . code = lastPressedCode ;
639
636
const lastPressedKey = Object . keys ( this . _downKeys ) . pop ( ) ;
640
- this . code = lastPressedKey ;
637
+ this . key = lastPressedKey ;
641
638
}
642
639
643
640
const context = this . _isGlobal ? window : this ;
@@ -920,9 +917,6 @@ function keyboard(p5, fn){
920
917
if ( typeof input !== 'string' ) {
921
918
return false ;
922
919
}
923
- if ( input . length === 1 && / [ 0 - 9 ] / . test ( input ) ) {
924
- return true ;
925
- }
926
920
return input . length > 1 ;
927
921
}
928
922
Original file line number Diff line number Diff line change @@ -190,10 +190,11 @@ suite('Keyboard Events', function() {
190
190
assert . isFalse ( isCode ( [ ] ) ) ;
191
191
} ) ;
192
192
193
- test ( 'returns false for single non-digit characters' , function ( ) {
193
+ test ( 'returns false for single non-digit and digit characters' , function ( ) {
194
194
assert . isFalse ( isCode ( 'a' ) ) ;
195
195
assert . isFalse ( isCode ( 'Z' ) ) ;
196
- assert . isFalse ( isCode ( '!' ) ) ;
196
+ assert . isFalse ( isCode ( '1' ) ) ;
197
+ assert . isFalse ( isCode ( '2' ) ) ;
197
198
assert . isFalse ( isCode ( ' ' ) ) ;
198
199
} ) ;
199
200
You can’t perform that action at this time.
0 commit comments