In js, press Ctrl + Enter to send the message. jsctrlenter sends the message.
1. Listen to the onkeydown event of textarea
Copy codeThe Code is as follows:
<Textarea tabindex = "1" class = "ie6ta" name = "contenthf. contenthf "onkeydown =" keySend (event); "title =" press ctrl + enter to send directly "> </textarea>
2. Send the form and reload the opener window (see Figure 4 ,)
function sbFrm() {var Contenthf=document.getElementById("Contenthf");var txtAr = Contenthf.getElementsByTagName("textarea")[0];if (txtAr.innerHTML == "") {txtAr.focus();return false;}Contenthf.submit();window.opener.afterReload();return false;}
3. When the ctrl key is pressed and the keycode is 13 (Press ENTER), the function of sending the form is called.
function keySend(event) {if (event.ctrlKey && event.keyCode == 13) {sbFrm();}}
4. If the current page is opened in window. open () mode, reload the function on the window. open page.
function afterReload() {setTimeout(function () {window.location.reload();}, 1000);}
Js implements the page shortcut key effect ---- now we have implemented the shortcut key effect for ctrl + enter to send information, and want to use alt + S
If (window. event. altKey & window. event. keyCode = 83)
Alert ("You are pressing alt + S ");
I tried IE6, but opera does not. It occupies the alt key. You can see that IE8 does not work.
Why do they send QQ messages by pressing Enter? I need to press Ctrl and Enter to send them.
Open a friend chat dialog box. Note that there is a "send" button, and a triangle drop-down button next to the button. Click it, you can press CTRL + press enter, or press enter directly, or in message mode.