var CtrlEnter = function(event, fun) {
if (event.ctrlKey && event.keyCode == 13)
fun();
};
使用
CtrlEnter(event,function(){alert('');});
come from
http://www.codeplex.com/sns/SourceControl/FileView.aspx?itemId=346758&changeSetId=18112
<form id="txtForm">
<textarea id="txt" />
</form>
对于这样的结构,使用以下js
$(function() {
$('#txt').keypress(function(event) {
if (event.ctrlKey && event.keyCode == 13) $('#txtForm').submit();
});
});
这还要用jquery?最简单的处理了
function quicksubmit(event,value1,value2)
{
if(event.ctrlKey && event.keyCode == 13)
{
//这里执行
submitcommentinf(value1,value2)
}
}
使用方式:<input type="text" size="20" id="comment" name="comment" onkeydown="javascript:quicksubmit(event,'<%=value1%>','<%=value2%>')"
<script language=javascript>
ie = (document.all)? true:false
if (ie){
function ctlent(eventobject){
if(event.ctrlKey && window.event.keyCode == 13){
this.document.form1.submit();
}
}
}
</script>
<form action="XXXXX" method=POST name=form1>
<textarea cols=95 name=Content rows=12 wrap=virtual onkeydown=ctlent()>
Ctrl+Enter提交内容信息
</textarea>
<input type=Submit value="Submit" name=Submit>
</form>