Wednesday, August 7, 2013

How to detect escape key press with javascript


Hi Frnds ...

I was using some code for escape key handle but it was working fine only in IE,  Not in Chrome. So i have stared doing some R&D and finally got solution :-)
And really it is working fine in all

<script type="text/javascript">
 document.onkeydown = function(evt) {
    evt = evt || window.event;
    if (evt.keyCode == 27) {
        alert("Escape");
    }
};
</scrip>

No comments:

Post a Comment