Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by tep on Nov 05, 2008 20:04
open dhtmlx forum
dhtmlxgrid: disable alt + any button

previously i asked about almost the same question but instead of the alt key i asked about the ctrl key.

you answered this to my previous question.
//
onKeyPress event provides 4 parameters
- key code
- state of ctrl key
- state of shift key
- native event object

you can use second parameter to check state of ctrl-key. If it is not enough - you can poll event object for any additional information.
//

my question now is, how do i know if alt key is pressed or should i ask how do i know the state of the alt key?
if ctrl button is pressed and another key is pressed state of ctrl key returns true, how do i get the same effect with alt keys?

another questiuon is what do you mean by "If it is not enough - you can poll event object for any additional information."?
that event return null as i tried looking at it..

thanks..
Answer posted by Support on Nov 06, 2008 02:06
mygrid.attachEvent("onKeyPress",function(code,ctrl,shift,ev){
        //ev -event object
        if (ev.altKey) alert("alt key pressed");
        return true;
})

The alt key handling may be problematic, some browsers handle alt key as "system" one, and don't generate javascript events for alt+something key combination. 
Answer posted by tep on Nov 06, 2008 14:29

so would this return the state of the alt key?

thanks..

Answer posted by tep on Nov 06, 2008 17:55

as ihave tried using this:

mygrid.attachEvent("onKeyPress",function(code,ctrl,shift,ev){
        //ev -event object
        if (ev.altKey) alert("alt key pressed");
        return true;
})

it doesnt seem to work..it says error on page, which basically means that when this line is executed it incurred an error..

thr code, ctrl and shift works perfectly fine but the ev.altKey does not work at all..whn i try to alert ev alone it works but returns undefined..

thanks in advance..