The text area should accept only numbers, comma, arrow keys (keyboard), space, Ctrl+c, Ctrl+v, Ctrl+x, Ctrl+a and it should be in javascript only. Following is my code :
<textarea onkeypress=' return validateKey(event)'></textarea>
<body>
<script type="text/javascript">
function validateKey(e){
var key= e.keyCode ? e.keyCode : e.charCode;
console.log(key);
if(key>47 && key <=57 || key>36 && key <=40 || key===44|| key===32 ||x|| key===8 || x|| key ===118 || key==99 || key === 120){
return true;
}
return false;
}
</script>
</body>
it works fine with chrome but in firefox, it takes the same keycode for 'a' and ctrl+a or cmd+a (mac) and so on for cut, paste, copy.
Is there any way in which i can treat ctrl+a and 'a' are two diff characters.