views:

136

answers:

1

Hi! I'm working on context sensitive help in DOJO-based web UI. such help should be also accessible using keyboard. this has brought me to dojo.keys.HELP that seems to be created for such purpose. unfortunately I can't find what key is it:/

in dojo._base.event it's mapped to key code 47 which is '/' ('?'). but after pressing '/':

console.log("current: " + event.keyCode + " / " + event.charOrCode + " target: " + dojo.keys.HELP);

returns:

current: 0 / / target: 47

I've tested most of keys on my keyboard and none has returned event.keyCode equal to dojo.keys.HELP . I'm using DOJO 1.3.1 .

A: 

I think you want to just use evt.charCode since charOrCode will return the keyChar (e.g. 'a') first.

For instance, this outputs 47 when I press '/' on my keyboard:

dojo.connect(
       dojo.query("html")[0],
       "onkeypress", 
       function(evt) { 
         console.log( evt.charCode ); 
       } 
);

Dojo normalizes the charCode so this is cross-browser compliant.

seth