Bind "f" to fullscreen mode
mojavelinux opened this issue · 8 comments
Many applications, presentation systems or otherwise, have gotten us used to being able to press the "f" key to enter fullscreen mode. I keep stumbling over this missing keybinding in bespoke.js while presenting. I hope to see this supported by bespoke-keys out of the box.
If you'd rather see this as a separate plugin, please let me know sooner rather than later so that I can get working on it. I'm really fine either way.
For reference about controlling full screen, see https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Using_full_screen_mode
This looks good to me. Would it be possible to write a test?
Did you see my comment in the pull request? I tried for several hours and in the end, I came up empty handed.
I actually got pretty close, mocking out the requestFullscreen
and exitFullscreen
methods, but the problem I was running into is that simulant was firing multiple keypress events for each call to pressKey and sometimes it was an even number and sometimes it was an odd number of calls.
If simulant behaves, I can probably get a test to work on PhantomJS. Any advice is welcome.
The more I think about this, the more I believe this should be a separate plugin. Although it seems like just another key, it's a very different concern from navigating the slides. I think making this a separate plugin aligns it with the spirit of keeping plugins simple and modular, which I'd like to honor. Do you agree?
Yep, sounds good to me :)
And we're live. https://github.com/opendevise/bespoke-fullscreen
I haven't published to npm yet, but this will be my first.
I still haven't worked out that testing problem yet.
I finally figured out the problem with simulant. The test suite creates multiple decks, which each register one or more event listeners. When the deck is destroyed (or goes out of scope) these event listeners are still active. If the test attached new HTML to the DOM, we start receiving the same event on multiple listeners.
I think this calls for having plugins respond to a "destroy" event which can allow them to cleanup their listeners. One of the most critical of those is the bespoke-keys plugin. I'll follow-up with a proposed change.