How can I subscribe to an event of pressing a button (e.g., ENTER)?

Question

How can I subscribe to an event of pressing a keyboard key to be able to perform certain actions upon pressing?

Answer

You can subscribe to any Ext component via Ext.util.KeyMap 

For example:

onEntityInitialized: function() {
   this.callParent(arguments);
 
   var map = new Ext.util.KeyMap({
      target: "AccountPageV2CodeTextEdit-el",
      key: Ext.EventObject.ENTER,
      fn: this.myHandler,
      scope: this
   });
},
myHandler: function() {
   alert("ENTER");
},

 

Like 0

Like

Share

0 comments
Show all comments