GWT: How to simulate F11 key press event?

1.4k Views Asked by At

I was wondering, can we trigger any key press even in GWT without JSNI? For example, say I have a image or a button in the header of my application. On click of it I want to go fullscreen on browser which simulates F11 key press. Again on click of the same image or button I want to exit from the full screen mode which simulates ESC key press.

I came to know through " How to make browser full screen using F11 key event through JavaScript " that we can do via java script, so it must be possible to do that via JSNI code snippet. Is there any other solution possible which doesn't use JSNI code?

1

There are 1 best solutions below

4
appbootup On

You would need to use Document.get().createKeyEvent or similar api.

NativeEvent event = Document.get().createKeyEvent(args.....);

DomEvent.fireNativeEvent(event, this);

Check which apis are deprecated before use.