Reputation:
How can I globally disable the use of the tab key on page? I found this question, but it uses jQuery and I am not using jQuery. I know I can set tabIndex equal to -1 to disable keyboard focus, but this is for a GWT web application that uses GWT-Ext, mixed with SmartGWT, and OpenLayers so it would be easier to just set it once in the page for the entire set of controls (and there are over a hundred different controls).
Upvotes: 0
Views: 1012
Reputation:
I ended up having to add this in my EntryPoint
class using SmartGWT:
Event.addNativePreviewHandler(new NativePreviewHandler()
{
@Override
public void onPreviewNativeEvent(NativePreviewEvent event)
{
// tab is key 9
if (event.getNativeEvent().getKeyCode() == 9)
{
event.cancel();
}
}
});
Upvotes: 0
Reputation: 167182
You can use something like this:
window.onkeydown = function() {
if (event.keyCode == 9) {
event.preventDefault();
}
}
I checked this by entering it in the console of Google Chrome and it disables the Tab key.
Upvotes: 1