Search code examples
javascriptextjsextjs4

ExtJS 4.2.1 - How can I toggle buttons in toolbar through keyboard commands?


I want to be able to activate buttons in ext toolbar from keyboard.. so the user could keep the mouse on the center window without having to choose buttons.

How can I do such thing ? if I use :

document.addEventListener('keydown', function (event))

than anytime I click somewhere in the browser (right and left panels also), buttons are being chosen (so I can't even write text in some text boxes).


Solution

  • I would look into using a KeyMap: http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.util.KeyMap

    It will give you much more granular control over your keystroke management while also helping you avoid having to do a bunch of keycode matching of your own.