87,955
社区成员
![](https://csdnimg.cn/release/cmsfe/public/img/topic.427195d5.png)
![](https://csdnimg.cn/release/cmsfe/public/img/me.40a70ab0.png)
![](https://csdnimg.cn/release/cmsfe/public/img/task.87b52881.png)
![](https://csdnimg.cn/release/cmsfe/public/img/share-circle.3e0b7822.png)
function InputChange() {
if (String.fromCharCode(event.keyCode) == "A")
{ alert('false'); return false; }
alert('true');
return true;
}
<Textarea id="TextArea1" style="width:1000px; height:300px; border-color:Green;" onkeydown="return InputChange();"></Textarea>
function InputChange() {
if (String.fromCharCode(event.keyCode) == "A")
{
setTimeout(function(){
alert('false');
},1)
return false;
}else {
alert('true');
return true;
}
}
function InputChange() {
if (String.fromCharCode(event.keyCode).toLocaleUpperCase() == "A")
{
alert('false');
return false;
}
alert('true');
return true;
}
<Textarea id="TextArea1" style="width:1000px; height:300px; border-color:Green;" onkeypress ="return InputChange();"></Textarea>
<Textarea id="TextArea1" style="width:1000px; height:300px; border-color:Green;" onkeydown="return InputChange(event);"></Textarea>
<script>
function InputChange(e) {return e.keyCode!=65; }
</script>