Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / ASP.NET

Find the key code using javascript

0.00/5 (No votes)
23 Nov 2011CPOL 22K  
In Text box key press event, find the pressed key code value using javascript
HTML
<input type="text" id="txtSearch"  önkeypress="searchKeyPress(event);" />

Java
function searchKeyPress(e)         
    {
        // look for window.event in case event isn't passed in
        if (window.event) { e = window.event; }
        if (e.keyCode == 13) {
           alert('Enter key pressed on the Text Box control'); 
        }         
    }

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)