I already have a series of events of keypress to trigger some sound, to run countdown clock and whatnot.
I also want to assign keycode to change the value of a couple of input[type=number], either subtract or add value by incremental of -1/+1 each key press. I have done some search but couldn't really give me the ultimate guide.
Here's what I have in the header.
function runScript(e){
if(e.keyCode == 32 && e.shiftKey){
gameclock();
}}
and on my html
<body onkeydown="runScript(event)">
...
<input id="whateverID1" type="number" value="00">
Let's say if I want to add #whateverID1 value by pressing = and subtract #whateverID1 value by pressing -, appreciate any guide to how can I achieve that. Thank you very much.
I have tried this but doesn't seem to work.
var CounterName = 0;
if(e.keyCode == 49 ) {
document.getElementById('whateverID1').value = ++CounterName;
}
if(e.keyCode == 50 ) {
document.getElementById('whateverID1').value = --CounterName;
}