From 1e5ca748a49b35ec698fc73d0420bb63534b9ae7 Mon Sep 17 00:00:00 2001 From: Hakim El Hattab Date: Sat, 26 Apr 2014 11:35:55 +0200 Subject: enable reveal.js keyboard shortcuts anywhere in notes window --- plugin/notes/notes.html | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'plugin/notes') diff --git a/plugin/notes/notes.html b/plugin/notes/notes.html index e488075..30e1669 100644 --- a/plugin/notes/notes.html +++ b/plugin/notes/notes.html @@ -208,6 +208,7 @@ connected = true; setupIframes( data ); + setupKeyboard(); setupNotes(); setupTimer(); } @@ -247,6 +248,19 @@ // Limit to max one state update per X ms handleStateMessage = debounce( handleStateMessage, 200 ); + /** + * Forward keyboard events to the current slide window. + * This enables keyboard events to work even if focus + * isn't set on the current slide iframe. + */ + function setupKeyboard() { + + document.addEventListener( 'keydown', function( event ) { + currentSlide.contentWindow.postMessage( JSON.stringify({ method: 'triggerKey', args: [ event.keyCode ] }), '*' ); + } ); + + } + /** * Creates the preview iframes. */ -- cgit v1.2.3