Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Aniki on Aug 28, 2008 13:37
open dhtmlx forum
onKeyPressed


Hi, I am keep playing with events and and keyboard functionality of the grid, I have a question about onKeyPress, I guess I understand how it works, but how does one reconcile the end of the key press?
I am trying to have a key activated, such as [shift] and while the shift is pressed, I would like a user to have an ability to do actionX, once shift is depressed, user should not have an ability to do an actionX.

How would a grid know if a user has stopped pressing a key?

Thank you.
Answer posted by Support on Aug 29, 2008 01:49
For monitoring status of global keys, it much simplier to use normal DOM events 

var shift_state=false;

dhtmlxEvent(document.body,"keydown",function(e){
       if ((e||event).shiftKey) shift_state=true;
});
dhtmlxEvent(document.body,"keyup",function(e){
       if (!(e||event).shiftKey) shift_state=false;
});