Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1470
Overriding ESC key on control
posted
  • ASP.Net Web Forms.

We have the following code in place when a user presses the ESC key we execute a post back to clear our screen:

// capture ENTER and execute Search, ESC and execute Clear.
		$(document).keypress(function (e) {
			if (e.which == "13") { //enter <-- Works
				document.getElementById('MainContent_btnSearch').click();
				return false;
			}
 
			if (e.which == "27") { // escape <-- fails when focus is in an Infragistics control.
				document.getElementById('MainContent_btnClear').click();
				return false;
			}
 
		});

It appears that the Infragistics control also uses the ESC to clear the value from the control.  Is there a way to prevent/override the Infragistics control from eating the ESC key?

The code handling the Enter key works fine in the same scenario.