document.getElementById('foo').onkeypress = function () { if ((event = event || window.event).keyCode == 97) { this.value += 's' return false; } };