65.9K
CodeProject is changing. Read more.
Home

Find the key code using javascript

emptyStarIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

0/5 (0 vote)

Nov 23, 2011

CPOL
viewsIcon

21991

In Text box key press event, find the pressed key code value using javascript

<input type="text" id="txtSearch"  önkeypress="searchKeyPress(event);" />
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'); 
        }         
    }