ExtJS添加热键

时间:2011-08-22 05:45:27

标签: javascript extjs hotkeys

我想在我的页面添加热键功能。

Ext.onReady(function () {
    Ext.util.KeyMap(document, {
        key: 'abc',
        handler: function () {
            alert("Hotkey was pressed!");
        }
    });
});

但事件不会发生。

2 个答案:

答案 0 :(得分:4)

Ext 3.3.1:

Ext.onReady(function () {
    new Ext.KeyMap(document, {
        key: 'abc',
        fn: function () {
            alert("Hotkey was pressed!");
        }
    });
});
Ext 4.0.2.a中的

Ext.onReady(function () {
    var map = new Ext.util.KeyMap(document,{
            //key : "abc" //doesn't work (mybe a bug)
            key: [65,66,67], // this works,
            fn: function(){ alert('a, b or c was pressed'); }
        }
    );
});

答案 1 :(得分:2)

使用fn密钥,而不是handler参数