keycode

JavaScript KeyCode vs CharCode

戏子无情 提交于 2019-11-26 02:19:26
问题 The problem: Limit allowed characters in a HTML input to a-z A-Z only. For business requirements this needs to be done on KeyPress so that the character simply isnt allowed to even appear in the input. Tab, enter, arrows, backspace, shift are all allowed. The user must be able to freely move in and out of the textbox, delete characters etc etc. This is the starting point of my code... var keyCode = (e.keyCode ? e.keyCode : e.which); However every value that I get in keyCode doesnt correspond