3.2.0

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
June 11,
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)
June 14,
nope. tried that already. it gives me an alert: 'Undefined'.
Jo
June 22,
Hi,
am actually looking for the same thing
why does it not work, Jo did u get any solutions

owl
July 7,
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
August 25,
how can i identify which key is pressed using javascript
Geetan
June 22,
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
December 10,

This topic is archived.

See also:


Back to support forum