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
Add setting to only display control characters #69296
Conversation
+1 |
Excited to try this! Does it handle multi-key shortcuts like Markdown preview too? |
It works for multi-key shortcuts, though screencast mode as a whole doesn't handle chords yet. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CC @mkenigs 👀
'properties': { | ||
'screencastMode.onlyControlKeys': { | ||
'type': 'boolean', | ||
'description': nls.localize('screencastMode.onlyControlKeys', "Only show control keys in Screencast Mode."), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe onlyModifierKeys
?
https://en.wikipedia.org/wiki/Modifier_key
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, pushed a commit! Honestly would probably be better to tweak this so it was just all keyboard shortcuts - thoughts?
@@ -193,13 +196,15 @@ export class ToggleScreencastModeAction extends Action { | |||
const label = keybinding.getLabel(); | |||
|
|||
if (!event.ctrlKey && !event.altKey && !event.metaKey && !event.shiftKey && this.keybindingService.mightProducePrintableCharacter(event) && label) { | |||
keyboardMarker.textContent += ' ' + label; | |||
if (!this.configurationService.getValue<boolean>('screencastMode.onlyControlKeys')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could just be another condition in the line above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assuming screencastMode.onlyControlKeys is true, if I change it back, an empty bar will show up across the screen when I type a non-modifier key. The unwritten else is to pass, leaving keyboardMarker.style.display = 'none' as it's set above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see what you mean. There's a bug here when modifiers for caps or foreign letters are pressed. I noticed it reading the comments for the mightProducePrintableCharacter
implementation. I propose an alternative.
const isShortcutKey = event.ctrlKey || event.metaKey;
const isModifierKey = isShortcutKey || event.altKey || event.shiftKey;
const isPlainCharacterKey =
!isModifierKey &&
this.keybindingService.mightProducePrintableCharacter(event) &&
label;
if (isPlainCharacterKey) {
keyboardMarker.textContent += " ";
}
keyboardMarker.textContent += label;
if (isShortcutKey || !this.configurationService.getValue<boolean>( "screencastMode.showOnlyShortcutKeys")
) {
keyboardMarker.style.display = "block";
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joaomoreno This looks close CC @mjbvz. Could we get an additional reviewer once @mkenigs implements changes?
} else { | ||
keyboardMarker.textContent = label; | ||
keyboardMarker.style.display = 'block'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And move this back below.
@texastoland wish I could have gotten to this sooner but anyways, I changed the setting to whether something is a keyboard shortcut, not just a modifier key. Seems to me like that's what's going to be desired most of the time. The feature as a whole is still kinda buggy but I think that's a separate issue. Let me know what you think |
Bonus feature: makes it super easy to add support for chords |
@mkenigs You seem to do a lot more here than expected:
Usually we prefer to have everything in separate PRs, but let's take it from here. The intended feature for this PR works fine. But not chord handling. Chords work in the following key sequence:
But they don't work in the following:
|
@joaomoreno thanks for looking at this! Also happy to split into multiple PRs if that would be easier. Changed it so that screencast mode only ever displays keys that have dispatch parts. That fixes the issue with chords, and it also allows slightly simpler logic regarding keys like shift. Chords still won't display properly if the screencast mode timeout is reached before that of chords - should those be changed to match? |
@joaomoreno Anything else I can do on this? |
Cleaned up a bit, removed the chord handling. Thanks! 🍻 |
Fixes #66674
Creates settings for Screencast Mode and a setting to only display control characters, and changes Screencast Action accordingly.