Recomended Method for Keyboard Shortcuts

Hello Everyone,
I am hoping to get some tips on how to deal with keyboard shortcuts. I’m building an app with dhtmlxlayout, dhtmlxgrid, dhtmlxtree, and dhtmlxmenu. One of my menu items creates a new row in one of the grids. I’d like to have a Ctrl+N hotkey or shortcut in addition to the menu. I see that I can use the ‘onKeyPress’ event for dhtmlxgrid, however, this event only seems to fire once the user has selected a row in the grid. Also, if the grid has no rows it will not fire at all. So, how does one implement a hotkey or shortcut to create a new row for the case where the grid is empty?

It seems like there should be an onKeyPress event for dhtmlxmenu, a kind of global onKeyPress event.

Thanks,
Eric

Hello
You can use method setHotKey():
docs.dhtmlx.com/doku.php?id=dhtm … _sethotkey
But it will set just additional text to your items.
There are no ready event handlers to set such actions you need. You can just write them manually.

Hello Darya,

I’ve got the hot keys showing up in my menu and I have the grid event onKeyPress working when there are rows in the grid, but, it won’t work when there are no grid rows. What component do you suggest I add handlers to?

Thanks,
Eric

Use event handler “onkeydown” or “onkeypress” on grid container (html element) or on document body.