CopyPastor

Detecting plagiarism made easy.

Score: 0.7569719620455756; Reported for: String similarity Open both answers

Possible Plagiarism

Plagiarized on 2017-03-07
by Muhammad Saqlain

Original Post

Original - Posted on 2012-12-21
by ᴍᴀᴛᴛ ʙᴀᴋᴇʀ



            
Present in both answers; Present only in the new answer; Present only in the old answer;

You can do this..
document.getElementById("id_of_textbox") .addEventListener("keyup", function(event) { event.preventDefault(); if (event.keyCode == 13) { document.getElementById("id_of_button").click(); }
Another way is using `onkeypress`
<input type="text" id="txtSearch" onkeypress="return searchKeyPress(event);" /> <script> function searchKeyPress(e) { // look for window.event in case event isn't passed in e = e || window.event; if (e.keyCode == 13) { document.getElementById('btnSearch').click(); return false; } return true; } </script>
You need to create a handler for the `onkeypress` action.
**HTML**
<input name="keywords" type="text" id="keywords" size="50" onkeypress="handleEnter(this, event)" />
**JS**

function handleEnter(inField, e) { var charCode; //Get key code (support for all browsers) if(e && e.which) { charCode = e.which; } else if(window.event) { e = window.event; charCode = e.keyCode; } if(charCode == 13) { //Call your submit function } }

        
Present in both answers; Present only in the new answer; Present only in the old answer;