Forum Moderators: open

Message Too Old, No Replies

accesskeys

without pressing 'enter'

         

sonic333

4:29 pm on Sep 7, 2004 (gmt 0)



is there a method for going to an accesskey link without pressing enter? (just pressing the key)...

thanks

Rambo Tribble

1:35 am on Sep 8, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Accesskeys appear to be very differently implemented in various browsers and on different OS's, but here's a script that demonstrates capturing keyboard events:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
if(navigator.appName!="Microsoft Internet Explorer"){
document.addEventListener("keydown",keyCapt,false); //code for Moz
}else{
document.attachEvent("onkeydown",keyCapt); //code for IE
}

function keyCapt(e){
if(typeof event!='undefined'){
var pressedKey=window.event.keyCode; //code for IE
}else{
var pressedKey=e.keyCode; //code for Moz
}
alert(pressedKey);
}

</script>
</head>
<body>

</body>
</html>

rjohara

3:22 am on Sep 8, 2004 (gmt 0)

10+ Year Member



Browser support is inconsistent: in some browsers, pressing an accesskey combination (control-1 for example) give focus to the link, and in others (like Mozilla, which I use) pressing the accesskey combination follows the link directly (no need to hit 'enter').

If you really want an extensive discussion, by far the best analysis of the whole accesskey situation is Jukka Korpela's essay [cs.tut.fi] on the subject. Access keys have the potential to be a real boon to web accessibility, but like so many things they aren't quite there yet.

dcrombie

2:22 pm on Sep 9, 2004 (gmt 0)



I was investigating this a couple of weeks ago. It seems that all the major browsers support accesskeys and hitting 'Enter' is only needed in MSIE on Windoze (not on MSIE(Mac)).