<input id="a"><br>Пробел нажат раз : <b id="b">0</b> <br> <button onclick="stop(this)">Stop it!</button>
<script>
var input = document.getElementById("a"),
log = document.getElementById("b"),
pressed=0,
handler = function (e){
if(e.keyCode===32){
log.innerHTML=++pressed;
}
}
input.addEventListener( 'keydown', handler, false);
function stop(a){
input.onkeydown = null;
input.removeEventListener('keydown', handler, false)
a.setAttribute('disabled','disabled')
}
</script>