I'd like to restrict keys that can be pressed.
$('.txtComments').keydown(function (event) {
var keys = new Array();
keys[0] = "8";
keys[1] = "46";
keys[2] = "37"
keys[3] = "39"
if(!(....)) //Check whether the keyCode is either of 8, 46, 37, or 39.
{
event.preventDefault();
}
});
Thanks for helping
var keys = [8,46,37,39];, then you can use$.inArrayandevent.which$.inArraylet excludeCode = [20, 16, 17, 18, 32]if ( excludeCode.includes(event.which) ) {}