Since keyCode and key are being deprecated within events like keypress, how do you implement checking for a specific key press?
I am trying to only allow specific key strokes within an input dom element. On the dom element I include onkeypress="someFunction(event)" and within someFunction I get the keyCode as follows: event.keyCode. This fails and so I looked up in the MDN and it states that keyCode is being deprecated. I tried using key in place of keyCode with same result. I am on a Windows 7 machine but this will be released to any device / browser that supports HMTL5. syntax: <input id="txt506PanDrySoilMass" class="uiRequiredField T506Calc T506BlankInput" type="text" style="text-align:center;" maxlength="6" onkeypress='Utilities.WholeNumberOnly(event);'/> Inside the Utilities namespace: WholeNumberOnly: function (event) {
var newDigit = String.fromCharCode(event.keyCode); <---fails here ... },
Code works within IE, Edge, Chrome and a few others. What is the best way to implement this within Firefox?