Skip to content

Commit

Permalink
Fixed bug #9 [Space spamming]
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengLinLei committed Oct 2, 2023
1 parent 8e68097 commit e210c26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
> Finding support and maintenance
>
> Collab with us [ISSUES](https://github.com/ZhengLinLei/stackblock.io/issues) and FORK
<h1 align="center">StackBlock.io v.1.0.1</h1>
Expand Down
18 changes: 15 additions & 3 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,25 @@ window.addEventListener('load', ()=>{
let eventType = supportsTouch ? 'touchstart' : 'click';
window.addEventListener(eventType, fncStart); // ADD FNC

let keyFree = true;
// PC Version
// Run fncStart function when the user press space key
window.addEventListener('keydown', function(e){
e.preventDefault();

if(e.keyCode === 32 || e.keyCode === 40){
fncStart();
// Space key
if(e.keyCode === 32 || e.keyCode === 40 || e.key === " "){
e.preventDefault();
if(keyFree){
keyFree = false;
fncStart();
}
}
});

// Liberate the key to be pressed again
window.addEventListener('keyup', function(e){
if(e.keyCode === 32 || e.keyCode === 40 || e.key === " "){
keyFree = true;
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion js/script.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e210c26

Please sign in to comment.