After writing a comment can not press CTRL + ENTER submit, to take a mouse point, it is painful things, do not know how many lazy people to dismiss the enthusiasm.
Want to add this feature to your comment box, then start:
Open the comments.php file in the topic, press Ctrl+f to search for "textarea", and then add the following code to his back:
The code is as follows |
Copy Code |
Onkeydown= "If" (event.ctrlkey&&event.keycode==13) {document.getElementById (' Submit '). Click (); return false}; " |
Add the above code to your form as
<input/> and so on.
If I press ENTER to submit, I'll just change the top.
The code is as follows |
Copy Code |
Onkeydown= "If" (event.keycode==13) {document.getElementById (' Submit '). Click (); return false}; " |
Save submit, and then have this function, by my own test, basically the market browser can be very good support, cool?
If you're using jquery, it's easier.
The code is as follows |
Copy Code |
$ ("body"). Bind (' KeyUp ', function (event) { if (event.keycode==13) { Document.form.submit (); } }); |
$ (' body ') is the time to indicate where the focus is, Ctrl + Eenter submitting the form is useful
. KeyPress () is the binding key press event
if (e.ctrlkey && E.which = | | e.which = 10) This is very simple, is to detect you are not pressed Ctrl and enter (E.which = = 13 Keyboard area return, E.which = = 10 keypad area back Car
$ (' #submit '). Click (); Press the button