contextmenu by keyboard

The contextmenu samples on the website (a.o. … namic.html) all are only activated by right-click with the mouse, the choices can only be selected by mouse.

Users would like to activate the contextmenu with the menu-button (usually on keyboards on the right side of the ALT key), and select their choice (like ‘add row’, ‘del row’) with the arrowkeys+enter. So that they can keep their hands on the keyboard while entering data.

Somebody got a sample how to enable this?

You can use “onKeyPress” event to configure what action on alt+key press. … onkeypress

I added a little code to the sample for testing this onKeyPress. It works for most keys, but it turns out the menu-button does not trigger this procedure. Working example on

mygrid.attachEvent("onKeyPress", function(code,cFlag,sFlag){
	alert("keypress code:" + code + " cFlag:" + cFlag + " sFlag:" + sFlag);
	return true;

Any alternatives to trigger an event by this menu-key?

We tested your sample. In all browsers menu-button has 93 code, in Opera it has “0” code.

Just tried a Windows OS, then it is working as per your message.

However on my laptop with Ubuntu 10.04 it is not working in Firefox, Chromium, Chrome or Opera.

Just tried some systems in our office:

  • On Ubuntu 8.04 in Firefox I get a code 93
  • On Ubuntu 9.04 in Firefox I get a code 93
  • On Lubuntu 10.04 in Chromium it is also not working

I’m curious if this is a specific problem of Ubuntu 10.04. I’m very interested in experiences with other OS.

What char code does button have controlled by browser. If Chromium on Lubuntu 10.04 doesn’t return char code for menu-button then it cannot be fixed with dhtmlxGrid component.

As a workaround for the problem with the menu-key I also defined the home-key (code 36) as a trigger for the contextmenu. So now I can show the contextmenu, with following code:

mygrid.attachEvent("onKeyPress", function(code,cFlag,sFlag){ if (code==93 || code==36) { onShowMenu(0,0,0); menu.showContextMenu(0,0); } return true; });

However it turns out the context-menu does not listen to the arrow-keys, as the grid does. I already tried adding an attachEvent for the menu, but this does not trigger any alert:

menu.attachEvent("onKeyPress", function(code,cFlag,sFlag){ alert("keypress code:" + code + " cFlag:" + cFlag + " sFlag:" + sFlag); });

Working example on

Hope for further suggestions how to solve this.

dhtmlxMenu doesn’t have “onKeyPress” event. If such requirement is critical in your case please open ticket at and we’ll provide customized version of dhtmlxMenu.