Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have tried this code
JavaScript
<script type="text/javascript">
      function ESCclose(e) {
          if (evt.keyCode == 27)
              window.close();
      }
  </script>
Posted
Updated 20-Feb-15 22:53pm
v4
Comments
Richard MacCutchan 21-Feb-15 4:18am    
Why have you tagged this ".NET4"? This is obviously a Javascript question.

1 solution

Have you wired for example ONKEYDOWN event to call your function?

Also it seems that you investigate evt parameter but the name of the parameter is e
So perhaps it should be
JavaScript
...
function ESCclose(evt) {
...
 
Share this answer
 
Comments
Member 11382784 21-Feb-15 4:52am    
<script type="text/javascript">
function ESCclose(evt) {
if (evt.keyCode == 27)
window.close();
}
</script>

i have tried this but it still not working
Wendelius 21-Feb-15 5:03am    
Do you actually call the function somewhere? For example in ONKEYDOWN event?
Member 11382784 21-Feb-15 5:24am    
onkeypress="ESCclose(evt)"

i have written this in div
Wendelius 21-Feb-15 5:34am    
onkeypress isn't necessarily fired for Esc. Try onkeydown
Member 11382784 21-Feb-15 5:44am    
still it is not working sir

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900