Get Correct keyCode for keypad(numpad) keys

前端 未结 6 1734
耶瑟儿~
耶瑟儿~ 2020-11-30 02:24

I\'m getting codes [96..105] by calling String.fromCharCode(event.keyCode) when pressing keys [0..9](digits) on the keypad. Th

6条回答
  •  一整个雨季
    2020-11-30 02:46

    Ok. But In Firfox Gecko It doesn't work. I use bellow code and I'm happy with it :)

    [somelement].onkeypress = function(e){
      var singleChar=e.key || String.fromCharCode(e.keyCode);
      console.log(singleChar);
    }
    

提交回复
热议问题