SharePoint Control Overrides My JavaScript “Keypress” Event

December 3, 2012

When you want to bind an event handler to the "keypress" JavaScript event, or trigger that event on an element, you can achieve this using JQuery  handler like .keypress( handler(eventObject) ) . For example, binding "keypress" event to a text box on your custom control : $("#input").keypress(function (event) { var code = (event.keyCode ? event.keyCode : event.which); if(code == 13) //Enter keycode // your logic here... } });   As you can see, the task is very simple and straightforward, but when dealing with SharePoint , sometimes things get pretty messy. Scenario:  You developed a custom control with a text box and used a "keypress" JavaScript event...