Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

Q1593 In the 'onKeyDown' or 'OnKeyPress' event handlers is there a way to retrieve a window's handle given the window's name?

You are here: irt.org | FAQ | JavaScript | Event | Q1593 [ previous next ]

Try:

<script language="JavaScript"><!--
var NS = (document.layers) ? 1 : 0;
var IE = (document.all)    ? 1 : 0;
// if (NS) document.captureEvents(Event.KEYPRESS); // uncomment if you wish to cancel the key

document.onkeypress = keyhandler;

function keyhandler(e) {
   if (NS) Key = e.which;
   else Key = window.event.keyCode;
   if (Key !=0) alert("Key pressed! ASCII-value: " + Key);
}
//--></script>

©2018 Martin Webb