<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>键盘事件之ctrl+回车提交留言</title>
<style></style>
<script type="text/javascript">
window.οnlοad=function(){
var oBtn1=document.getElementById('btn1');
var oTxt=document.getElementById('txt1');
var oTxt1=document.getElementById('txt2');
oBtn1.οnclick=function(){ //点击提交按钮来提交留言
oTxt1.value=oTxt1.value+oTxt.value+'\n';
oTxt.value='';
}
oTxt.οnkeydοwn=function(ev){
var oEvent=ev||event;
if(oEvent.keyCode==13&&oEvent.ctrlKey) //如果按下ctrl+enter键也可以提交留言
{
oTxt1.value=oTxt1.value+oTxt.value+'\n';
oTxt.value='';
}
}
}
</script>
</head>
<body>
<div style="margin:100px auto;text-align:center;">
<input id='txt1' type="text">
<button id='btn1' type="button" name="button">提交</button>
<br>
<!-- <input type="button" value="提交"> -->
<textarea id='txt2' name="name" rows="10" cols="80"></textarea>
</div>
</body>
</html>