how to capture key events in the div tag page?

advertisements

Can any one tell me how to capture key events in div tag??

I wrote this code but it is not working?

<div id="SDiv" style="background-color: White; " onkeypress="kypress()">
     <asp:Label ID="LblSaveAndMoveNext" runat="server" Visible="False" Text="Save"></asp:Label>
</div>

<script type="text/javascript">
    function kypress() { EnableButtons(true);}
</script>


You must have a focus in order to trigger the keypress event.

Or you could apply the keypress on the document object.

Using jQuery:

$(document).keypress(function(){
     /*do something*/
});