:: Forum >>

relaying keypresses to my main script

Hi, i really like what you've done so far. Congratz on one of the most amazing javascript-widgets i've ever seen.

I have been struggling on this problem for a day now, so i thought it might be better to ask it here, since i'm quite sure some other people will need the following functionality too. Here goes..

Is it possible to divert keypresses in the grid to another keyhandler without interrupting the workings of the grid itself? I need this because in my main app, the function keys will be shortcuts to various stuff.

I tried to do this already, but failed (none of the keys work anymore):

var newkeypress = function (event)
{
var keypressevent = obj.getEvent("onkeydown");

var dr = []; // I had to define this since i can't access kbActions for some reason
dr[33]="pageUp";
dr[34]="pageDown";
dr[35]="end";
dr[36]="home";
dr[38]="up";
dr[40]="down";

if(dr[event.keyCode]) {
keypressevent.call(this, event);
}
else {

alert(event.keyCode);
}
}

obj.setAction("mykeyhandler", function (event) {newkeypress(event)});
obj.setEvent("onkeydown", function(event) { obj.action("mykeyhandler"); });

Is there something i'm missing?
Jo
Friday, June 11, 2004
I did not try the code, but here is my guess:

var keypressevent = obj.getEvent("onkeydown");

var newkeypress = function (event)
{

var dr = []; // I had to define this since i can't access kbActions for some reason
dr[33]="pageUp";
dr[34]="pageDown";
dr[35]="end";
dr[36]="home";
dr[38]="up";
dr[40]="down";

if(dr[event.keyCode]) {
keypressevent.call(this, event);
}
else {

alert(event.keyCode);
}
}

obj.setEvent("onkeydown", newkeypress);
Alex (ActiveWidgets)
Monday, June 14, 2004
nope. tried that already. it gives me an alert: 'Undefined'.
Jo
Tuesday, June 22, 2004
Hi,
am actually looking for the same thing
why does it not work, Jo did u get any solutions

owl
Wednesday, July 7, 2004
owl, no i haven't actually. i just urge all users of my program to release focus from the grid first, before pressing a key-combination. I'll probably going to come back to this problem though. So if i find something, i'll let it know here.

Jo
Wednesday, August 25, 2004
how can i identify which key is pressed using javascript
Geetan
Thursday, June 22, 2006
Try this, it works !!

function hotKeys (event) {
event = (event) ? event : ((window.event) ? event : null);

var charCode = (event.charCode) ? event.charCode : ((event.which) ? event.which : event.keyCode);

alert(charCode);
}

<body onkeydown="hotKeys(event);">
August
Sunday, December 10, 2006

This topic is archived.


Back to support forum

Forum search