I use this code for keyboard input on a calculator in Javascript. All the numbers and the decimal work, but the 'clear all' doesn't. Does anyone have an idea why? Am I using a wrong ascii code?
//Add keyboard input
$(document).keypress(function(event){
    var keycode = (event.keyCode ? event.keyCode : event.which);
    if (keycode === 49) {
        $("#one").click();
   } else if (keycode === 50) {
        $("#two").click();
    } else if (keycode === 51) {
        $("#three").click();
    } else if (keycode === 52) {
        $("#four").click();
    } else if (keycode === 53) {
        $("#five").click();
    } else if (keycode === 54) {
        $("#six").click();
    } else if (keycode === 55) {
        $("#seven").click();
    } else if (keycode === 56) {
        $("#eight").click();
    } else if (keycode === 57) {
        $("#nine").click();
    } else if (keycode === 48) {
        $("#zero").click();
    } else if (keycode === 127 || keycode === 08) {
        $("#clearall").click();
    } else if (keycode === 46 || keycode === 44) {
        $("#decimal").click();
    }  
});
You can find the complete project on JSFiddle: http://jsfiddle.net/depauw/XfRDx/ I don't think that the 'clearall' function is broken. when i push the button on the screen, the clear all function is executed.
What i want to achieve is: when a user made a mistake inputting his/her number, he/she can delete it by pressing the delete button and/or the backspace button.
I already tried replacing 'keypress' by keydown of keyup, but that disabled the keyboard input. That was probably a stupid mistake, but i'm a real beginner, learning with tutorials, sample codes, and bits of code from everywhere!
Kind regards for your help!!!, Christophe