Reputation:
I made this game counter: https://mikesgames.neocities.org/Games/Cursor%20Counter/counter.html for my friends and I (I'm in middle school so it doesn't have to be perfect).
I want to have a feature where someone presses the key(cursor) the game grants the initiator 10,000 points (in my game its cursors).
I believe I will need JavaScript for this. I have a little cheat button like this-
<div class="button" onclick="cheat()"></div>
btw I'm using https://neocities.org
Upvotes: 2
Views: 324
Reputation: 339
Add the following Javascript to call the cheat method when N is pressed
document.onkeydown = function(e){
e = e || window.event;
var key = e.which || e.keyCode;
if(key===78){
cheat();
}
}
If you want to add additional functionality for other keys then a useful list can be found here - https://css-tricks.com/snippets/javascript/javascript-keycodes/
Upvotes: 2