View Full Version : Need to recognize Shift+Tab (BackTab)
DavdMitchell
09-05-2002, 03:43 AM
I am writing a script that works with each key pressed and have recognized that "9" is the tab key, which I use to exit the script and set focus on the next field. What I now need to do is "backup" into the previous field when Shift+Tab is pressed.
Does anyone know how this combination can be recognized?
joh6nn
09-05-2002, 04:39 AM
i got this from a former member of the forum. it shows how to get keycodes cross browser. hope it helps.
<Script language="JavaScript"><!--
function chkKey(evt) {
var mykey, alt, ctrl, shift;
if (window.Event) {
mykey = evt.which;
alt = (evt.modifiers & Event.ALT_MASK) ? true : false;
ctrl = (evt.modifiers & Event.CONTROL_MASK) ? true : false;
shift = (evt.modifiers & Event.SHIFT_MASK) ? true : false;
} else {
mykey = event.keyCode;
alt = event.altKey;
ctrl = event.ctrlKey;
shift = event.shiftKey;
}
if (mykey!=0 && mykey!=16 && mykey!=17 && mykey!=18) {
alert("That key is #"+mykey+" or ' "+String.fromCharCode(mykey)+" '\n\n"+
"alt="+alt+",\n"+
"ctrl="+ctrl+",\n"+
"shift="+shift);
}
return true;
}
if (window.Event)
document.captureEvents(Event.KEYDOWN);
document.onkeydown = chkKey;
//--></Script>
DavdMitchell
09-05-2002, 05:05 AM
Event.shiftKey is just what I needed. Thanks.
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.