Pls Go On
Pls Go On

Reputation: 51

Cannot create a keyboard listener in sencha 2.2.1

I need to create a keyboard navigation in application based on ExtJs(sencha 2.2.1). It's my 2nd day in Extjs.

I tried to use KeyMap, but it is missing in current version that I used also Ext.EventManager was deprecated since 2.0.0 version.

So I tried that like that:

1st try:

Ext.define('MyApp.view.MyView', {
 ...
initialize: funcion() {
var me = this;
me.callParent();
me.element.on({
 keyup:function() { //isn't work, cuz this event doesn't handle, but tap:func() works.
  console.log();
}
});

2nd try:

//in my controller
Ext.define('MyApp.controller.MyController', {
 ...
 init: function() {
  this.control({
   'myViewId': {
     'afterrender':this.keyBinding
    }
  })
},
 keyBinding: function (view, options) {
    debugger;
      Ext.EventManager.on(view.getEl(), 'keyup', function (evt, t, o) {
          console.log("LOGGING EVENT ========================================================================");
      }, this);
}
//but nothing happens

Also i tried something like that:

Ext.getCmp('myViewId').element.on('keydown', function (f, e) {
       console.log("KEY DOWN==============================================");
    });

But events linked with key doesn't occur

Help me please or just give me some advice or code example. How can I add key listener in my app?

This is a doc that I use: Sencha docs

Upvotes: 2

Views: 92

Answers (1)

olegtaranenko
olegtaranenko

Reputation: 3880

keyup and keydown event are binding only for input field in Sencha Touch, because of ... touch nature :) Keyboard on the mobile device not always visible. If you want to create both desktop and mobile app on the same codebase - try ExtJS 6.0. ~$4300 for getting start license.

Upvotes: 1

Related Questions