1document.body.onkeyup = function(e){
2 if(e.keyCode == 32){
3 //your code
4 }
5}
1
2var hits = 0;
3var hitElement = document.querySelector('.hits');
4document.body.onkeyup = function (e) {
5 if (e.keyCode == 32) {
6 addHit();
7 }
8}
9
10var addHit = function () {
11 hits++;
12 renderHits();
13}
14
15var renderHits = function () {
16 hitElement.innerHTML = hits;
17}
18
19var resetHits = function () {
20 hits = 0;
21 renderHits();
22}
23
24