<html>
<head>
<title></title>
</head>
<body>
<div>文本框:</div>
<textarea>按下ESC选中我</textarea>
<script src="jquery.min.js" ></script>
<script type="text/javascript">
function hotkey()
{
var a=window.event.keyCode
if(a==27)
{
$('textarea').select()
}
}
// 初始化加载
$(document).ready(function () {
document.onkeydown = hotkey
})
</script>
</body>
</html>
function escKeyPress(){var evObj = document.createEvent('KeyboardEvent')
evObj.initKeyEvent("keypress", true, false, null, false, false, false, false, 27, 0)
var booleanR = document.documentElement.dispatchEvent(evObj)
}
这个是模拟按下esc你可以参考一下