This article describes how to directly press Ctrl + Enter to submit the form implementation program after we Enter the content. this method is generally used in textarea. other input fields are not required. Developed using jQuery plug-ins. The code is as follows:
JQuery. fn. extend ({/*** ctrl + enter submit form * @ param {Function} the Function executed after the fn operation * @ param {Object} thisObj pointer scope */ctrlSubmit: function (fn, thisObj) {var obj = thisObj | this; var stat = false; return this. each (function () {$ (this ). keyup (function (event) {// Only Press ctrl, wait for the enter key to press if (event. keyCode = 17) {stat = true; // cancel waiting for setTimeout (function () {stat = false ;}, 300) ;}if (event. keyCode = 13 & (stat | event. ctrlKey) {fn. call (obj, event );}});});}});
Usage:
$ ("# Textarea"). ctrlSubmit (function (event) {// submit the code here });
Is it very simple and practical? I hope everyone will like it.