1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
<html>
<head>
<script src="jquery-1.4.2.js"></script>
<script src="jquery.hotkeys.js"></script>
</head>
<body>
<input type="button" id="bindCtrlS" value="bind ctrl+s" />
<input type="button" id="unBindCtrlS" value="unbind ctrl+s" />
<script>
function bindCtrlS(){
jQuery(document).bind('keydown', 'ctrl+s',function (evt){
alert("Ctrl+S");
return false;
});
}
function unBindCtrlS(){
jQuery(document).unbind('keydown', 'ctrl+s');
}
$(document).ready(function(){
$('#bindCtrlS').bind('click', bindCtrlS);
$('#unBindCtrlS').bind('click', unBindCtrlS);
}
);
</script>
</body></html>
|