Javascript examples for DOM:Key Event
check key code from event keyCode and which property
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> var arrForbiddenCodes = [97, 98, 99]; function CheckKey(event) {/*from w w w .j av a2s.c om*/ var keyCode = event.keyCode || event.which; for (var i = 0; i < arrForbiddenCodes.length; i++) { if (arrForbiddenCodes[i] === keyCode) return false; } return true; } </script> </head> <body> <textarea onkeypress="return CheckKey(event);"></textarea> </body> </html>