日期:2014-05-16  浏览次数:20399 次

使用JS监听键盘两个组合键触发的事件

今天要解决“粘贴”的一个问题,特意在网上查了关于组合键触发事件的问题

?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<script src="lib/jquery-1.6.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(
	function(){
		document.onkeydown = function()
		{
			var oEvent = window.event;
			if (oEvent.keyCode == 13 && oEvent.ctrlKey) {
				alert("你按下了ctrl+enter");
			}
		}
	}
);
</script>
<title>无标题文档</title>
</head>
<body>
</body>
</html>

?