Create event for arrow keys in extjs

余生长醉 提交于 2019-12-11 04:03:55

问题


How to get the char codes of the arrow keys in extjs?

I tried the below code which is working good to get the char codes of all the keyboard buttons but not the arrow keys(also Backspace).

Ext.getDoc().on('keypress', function(event, target) {
        console.log(event.getCharCode())
});

Before asking here, I have gone through the documentation which I can't understand.

and also If I press backspace then the page is redirecting to previous page. I am planning to keep my own function in future on backspace. How to override it in extjs?

I am a beginner. So, please provide simple example..


回答1:


To archive this you need to use monitoring like

instance.mon(Ext.getDoc(), Ext.EventManager.getKeyEvent(), instance.callBack, instance)

see JSFiddle (I think you can check for the right key)




回答2:


There is an example of exactly that in the documentation: http://dev.sencha.com/deploy/ext-4.1.0-gpl/examples/keynav/keynav.html



来源:https://stackoverflow.com/questions/14706218/create-event-for-arrow-keys-in-extjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!