diff --git a/README.md b/README.md index fbee859..1e48ac0 100644 --- a/README.md +++ b/README.md @@ -81,6 +81,8 @@ Always available: - `command-.`: End presentation - `command-shift-f`: Toggle full-screen mode +*Windows and Linux users can use Ctrl instead of Command.* + When presenting (key-control is active): - `N`/`rightArrow`/`downArrow`/`pageDown`: Next slide diff --git a/slide-deck.js b/slide-deck.js index f1020fd..0db190a 100644 --- a/slide-deck.js +++ b/slide-deck.js @@ -169,7 +169,7 @@ class slideDeck extends HTMLElement { this.shadowRoot.addEventListener('keydown', (event) => { event.stopPropagation(); - if ((event.key === 'k' && event.metaKey) || event.key === 'Escape') { + if ((event.key === 'k' && this.cmdOrCtrl(event)) || event.key === 'Escape') { event.preventDefault(); this.#controlPanel.close(); } @@ -491,9 +491,13 @@ x this.goTo(this.#slideFromStore()); } + // Detect Ctrl / Cmd modifiers in a platform-agnostic way + #cmdOrCtrl = (event) => event.ctrlKey || event.metaKey; + #keyEventActions = (event) => { + // always available - if (event.metaKey) { + if (this.#cmdOrCtrl(event)) { switch (event.key) { case 'k': event.preventDefault();