Popup Key Value Description:
Console.log (Ev.keycode)
Enter: 13
Ctrl:17
1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "UTF-8">5 <title>Message submission System</title>6 <Metaname= "Author"content= "Guo Jufeng/[email protected]"/>7 </Head>8 9 <Body>Ten <inputtype= "text"name=""ID= "txt"value="" /> One <inputtype= "button"name=""ID= "BTN"value= "Submit" /><BR/> A <textareaname=""rows= " the"cols= "a"ID= "Txtarea"></textarea><BR/> - </Body> - </HTML>
HTML code
1<script type= "Text/javascript" >2Window.onload =function() {3 varOtxt = document.getElementById ("TXT");4 varOBTN = document.getElementById ("btn");5 varOtxtarea = document.getElementById ("Txtarea");6Obtn.onclick =function() {7 addtxt ();8 };9Otxt.onkeydown =function(EV) {Ten varEV = EV | |window.event; One //Console.log (Ev.keycode) A if(Ev.keycode = = && Ev.keycode = = 17) { - addtxt (); - } the if(Ev.keycode = = 13) { - addtxt (); - } - }; + - functionAddtxt () { + if(Otxt.value = = "") { AAlert ("Please enter content"); at } -Otxtarea.value =Otxt.value; -Otxt.value = ""; - }; - } -</script>
JS
js-make message submission system (support CTRL + ENTER)