ho testato il char code dei caratteri e li ho messi nell'array.
questo sembrerebbe funzionare:
codice:
<input type="text" value="" onkeydown="return checkChar(event);">
<script>
function checkChar(evt) {
const permessi = Array(
8, 32, 39, 46, 59, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 222
);
const charCode = (evt.which) ? evt.which : evt.keyCode;
console.log(charCode);
if (!permessi.includes(charCode)) {
return false;
}
return true;
}
</script>