File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 654654 let timer = null ;
655655 let progressTimer = null ;
656656 let keyboardMode = false ;
657+ let pressedKeys = { } ;
657658 let cpsData = { history : [ ] , bestCPS : 0 , totalClicks : 0 , totalTests : 0 } ;
658659 try {
659660 const savedData = localStorage . getItem ( 'cpsData' ) ;
701702 if ( e . code === 'Space' ) {
702703 e . preventDefault ( ) ;
703704 }
704- if ( isRunning ) {
705+ if ( isRunning && ! pressedKeys [ e . code ] ) {
706+ pressedKeys [ e . code ] = true ;
705707 handleKeyPress ( ) ;
706708 }
707709 } ) ;
710+ document . addEventListener ( 'keyup' , ( e ) => {
711+ if ( pressedKeys [ e . code ] ) {
712+ delete pressedKeys [ e . code ] ;
713+ }
714+ } ) ;
708715 if ( startTestBtn ) {
709716 startTestBtn . addEventListener ( 'click' , ( ) => {
710717 if ( ! isRunning && ! isReady && ! inCooldown ) {
867874 isRunning = false ;
868875 isReady = false ;
869876 clicks = 0 ;
877+ pressedKeys = { } ;
870878 if ( clickCount ) clickCount . textContent = '0' ;
871879 if ( currentCPS ) currentCPS . textContent = '0.0' ;
872880 if ( progressBar ) progressBar . style . width = '0%' ;
You can’t perform that action at this time.
0 commit comments