The implementation method is very simple, just a few lines of javascript can be done. Add this shortcut key to WordPress:
1. Open the comments. Php file in the template and find the following content. The code is as follows:
<Form action = "<? Php echo get_option ('siteurl');?> /Wp-comments-post.php "method =" post "id =" commentform "name =" commentform ">
<? Php if ($ user_ID):?>
If your form tag does not have the name = "commentform" attribute, add it.
2. Pull down a bit and you can see two similar lines. The code is as follows:
<P> <textarea name = "comment" id = "comment" cols = "55" rows = "10" tabindex = "4"> </textarea> </p>
<P> <input type = "submit" id = "submit" tabindex = "5" value = "submit message"/> </p>
If the textarea tag does not have the id attribute, add it according to the above content. If name = "submit" is found in the second line, delete it. If you find it still does not work, change id = "submit" to id = "submitit.
3. At last, add the following javascript code under form and save it. The code is as follows:
<Script type = "text/javascript> <! -- // --> <! [CDATA [//> <! --
Var commenttextarea = document. getElementById ('Comment ');
Commenttextarea. onkeydown = function quickSubmit (e ){
If (! E) var e = window. event;
If (e. ctrlKey & e. keyCode = 13 ){
Document. getElementById ('submit '). click ();
}
};
// --> <!]>
</Script>
For other information, see JQuery press enter to submit the form. The code is as follows:
$ ("Body"). bind ('keyup', function (event ){
If (event. keyCode = 13 ){
Document. form. submit ();
}
});
Principle: add a keyup event to the body
The code is as follows:
<Body onkeyup = "autosubmit ()"> // add a listener event
Function autosubmit () {// event-triggered function
If (event. keyCode = 13 ){
Document. form. submit ();
}
}
The code for js implementation is as follows:
<Form action = http://www.111cn.net method = "post" name = "myForm">
<Input type = "text"/>
<Input type = "submit" value = "submit" name = "tijiao"> <font color = "#999999"> press enter to submit the form </font>
</Form>
</Body>
</Html>
<Script language = "JavaScript" type = "text/javascript">
Document. onkeydown = function (evt ){
Var evt = window. event? Window. event: evt;
If (evt. keyCode = 13)
{
Document. forms ["myForm"]. submit ();
}
}
</Script>
If you want to prevent the entry from submitting a form for page creation, it is to listen to the onkeydown event of the form, and add onkeydown = "if (event. keyCode = 13) return false;" then OK.