Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle Ctrl and Cmd in keyboard events #18

Merged
merged 3 commits into from
Jan 11, 2024
Merged

Handle Ctrl and Cmd in keyboard events #18

merged 3 commits into from
Jan 11, 2024

Conversation

jerivas
Copy link
Member

@jerivas jerivas commented Jan 10, 2024

Related Issue(s)

Fixes #17

Steps to test/reproduce

Use either Cmd or Ctrl for keyboard shortcuts

Copy link

netlify bot commented Jan 10, 2024

Deploy Preview for slide-deck ready!

Name Link
🔨 Latest commit 4659aa5
🔍 Latest deploy log https://app.netlify.com/sites/slide-deck/deploys/65a02430d4c7d90008bec9c4
😎 Deploy Preview https://deploy-preview-18--slide-deck.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

slide-deck.js Outdated
@@ -455,9 +455,12 @@ class slideDeck extends HTMLElement {
this.goTo(this.slideFromStore());
}

// Detect Ctrl / Cmd modifiers in a platform-agnostic way
cmdOrCtrl = (event) => event.ctrlKey || event.metaKey;
Copy link
Member Author

@jerivas jerivas Jan 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could try to be clever and do platform sniffing to respond to only one of these, but from a quick investigation and issues like this, it seems like just handling both should be enough.

Copy link
Member

@mirisuzanne mirisuzanne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, and it still works on mac :)

slide-deck.js Outdated
@@ -455,9 +455,12 @@ class slideDeck extends HTMLElement {
this.goTo(this.slideFromStore());
}

// Detect Ctrl / Cmd modifiers in a platform-agnostic way
cmdOrCtrl = (event) => event.ctrlKey || event.metaKey;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be a private method (the other PR is making most of the others private, so this would match that, eventually).

Copy link
Contributor

@jamesnw jamesnw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

Copy link

@dvdherron dvdherron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works great! I think the only shortcut that I couldn't get to work was ctrl + shift + f for toggling full screen mode but otherwise this works great.

@mirisuzanne
Copy link
Member

Works great! I think the only shortcut that I couldn't get to work was ctrl + shift + f for toggling full screen mode but otherwise this works great.

@dvdherron What browser are you using, and what shows in the console when you try it? Any chance you're running into #1

@dvdherron
Copy link

dvdherron commented Jan 11, 2024

Works great! I think the only shortcut that I couldn't get to work was ctrl + shift + f for toggling full screen mode but otherwise this works great.

@dvdherron What browser are you using, and what shows in the console when you try it? Any chance you're running into #1

Hmm. That's interesting. I get the same response in Chrome and Firefox. I tried this with the caps-lock key on and it worked in both browsers.

And once I get the slides to go fullscreen with the shortcut I can only see the first slide. Is that expected?

@mirisuzanne
Copy link
Member

Hmm. That's interesting. I get the same response in Chrome and Firefox. I tried this with the caps-lock key on and it worked in both browsers.

Strange. I'm not sure how to debug that. I'm also not sure if this is the right shortcut for fullscreen.

And once I get the slides to go fullscreen with the shortcut I can only see the first slide. Is that expected?

Nope. But that seems like a separate issue we can add to the fullscreen issue pile.

@mirisuzanne
Copy link
Member

I'd be real tempted to merge this and remove fullscreen support until we can get it working correctly. Fullscreen is not a feature that I expect to use in the workshop.

@mirisuzanne mirisuzanne merged commit fd22686 into main Jan 11, 2024
4 checks passed
@mirisuzanne mirisuzanne deleted the ctrl-or-meta branch January 11, 2024 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Keyboard shortcuts not working on Windows
4 participants