How to restrict tab key handler event in gwt

天大地大妈咪最大 提交于 2020-07-22 21:38:24

问题


I am using GWT components for web page. In my page I used ten text boxes. I want to block "tab" key event for navigate one text box to another text box.

Expected Approach: If I pressed tab key it wont go to another text box.


回答1:


You can do somthing like this.

window.onkeydown = function() {
    if (event.keyCode == 9) {
        event.preventDefault();
    }
}



回答2:


Use NativePreviewEventHandler and use the logic mentioned by Mayank Pandya, which is

if (event.keyCode == 9) {
        event.preventDefault();
    }

Check for the Tabkey keycode. I am not sure about it.



来源:https://stackoverflow.com/questions/28063277/how-to-restrict-tab-key-handler-event-in-gwt

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