mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-09-05 19:08:17 +00:00
macOS: get proper unshifted codepoint with ctrl pressed (#7150)
Fixes a regression where `C-S-c` stopped working properly in both legacy and Kitty modes (although the Kitty mode side only affected alternates and not the key itself so it probably worked fine in most programs). The issue is that `charactersIgnoringModifiers` changes behavior if `control` is pressed, so it doesn't really ignore all modifiers. We have to use `characters(byApplyingModifiers:)` to get the proper unshifted codepoint when `control` is pressed.
This commit is contained in:
@@ -33,11 +33,13 @@ extension NSEvent {
|
||||
.subtracting([.control, .command]))
|
||||
|
||||
// Our unshifted codepoint is the codepoint with no modifiers. We
|
||||
// ignore multi-codepoint values.
|
||||
// ignore multi-codepoint values. We have to use `byApplyingModifiers`
|
||||
// instead of `charactersIgnoringModifiers` because the latter changes
|
||||
// behavior with ctrl pressed and we don't want any of that.
|
||||
key_ev.unshifted_codepoint = 0
|
||||
if type == .keyDown || type == .keyUp {
|
||||
if let charactersIgnoringModifiers,
|
||||
let codepoint = charactersIgnoringModifiers.unicodeScalars.first
|
||||
if let chars = characters(byApplyingModifiers: []),
|
||||
let codepoint = chars.unicodeScalars.first
|
||||
{
|
||||
key_ev.unshifted_codepoint = codepoint.value
|
||||
}
|
||||
|
Reference in New Issue
Block a user