ENTER键按下事件不工作dojo 1.10

时间:2014-12-15 15:28:03

标签: javascript dojo

当我按下回车键

时,这不起作用
var loginContent = new ContentPane({
    id: 'lgncontent',
    content: loginboxes,
    onKeyPress: loginKeyPress
});

function loginKeyPress(evt) {
    require(["dojo/keys", "dojo/dom", "dojo/on"], function (keys, dom, on) {
        on(dom.byId("lgncontent"), "keypress", function (evt) {
            switch (evt.charOrCode) {
                case keys.ENTER:
                    console.log('ENTER!');
                    sendCred(lForm.getValues());
                    break;
            }
        });
    });
}

1 个答案:

答案 0 :(得分:1)

解决 而不是函数,我必须在dlg定义后添加以下行:

var btnClick = dlg._onKey = function(evt) {
 key = evt.keyCode;
 if (key == dojo.keys.ENTER) {
  sendCred(lForm.getValues());
 }
}