Skip to content

macOS: fix non control keys are not working for AppleScript - #13205

Merged
mitchellh merged 1 commit into
ghostty-org:mainfrom
bo2themax:push-0f19080e
Aug 27, 2026
Merged

mitchellh merged 1 commit into
ghostty-org:mainfrom
bo2themax:push-0f19080e

Conversation

@bo2themax

@bo2themax bo2themax commented Jul 5, 2026 •

Copy link
Copy Markdown
Member

send key only works for control keys like enter currently; this adds (fixes) the support for other keys listed as available. Found by @paaloeye in #13180

The core of this fix is relying on UCKeyTranslate to get the corresponding character and code point from a key code using KeyboardLayout.character(for:modifiers:).

ScriptKeyEventCommand now respects macos-option-as-alt, and attach text, unshifted_codepoint and consumed_mods under the same condition as a manual input events like in performKeyEquivalent and localEventKeyDown.

AI Disclosure

Claude did the heavy lifting, I reviewed and rephrased some of the comments it generated. And ofc reviewed and tested myself.

@paaloeye paaloeye left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Well done!

Tested it in my harness and it works as expected.

Test command: gtty surface broadcast --engine swift --offset -3..-1.
One would need four surfaces and Nushell installed.

@paaloeye

Copy link
Copy Markdown
Contributor

I've been daily driving Ghostty with that — couldn't find any problems with it.
@bo2themax Is anything missing here? It wasn't trivial to discover using send key with anything other than enter, IMO it's worth updating the docs. I'm happy to give it go.

@bo2themax

Copy link
Copy Markdown
Member Author

IMO it's worth updating the docs. I'm happy to give it go.

You're welcome to open a pr to the website once this is merged.

@bo2themax
bo2themax force-pushed the push-0f19080e branch 3 times, most recently from 5f317f8 to 07646de Compare August 10, 2026 10:08
@bo2themax
bo2themax force-pushed the push-0f19080e branch 2 times, most recently from 071404f to 6b3ea38 Compare August 14, 2026 06:59
@bo2themax
bo2themax force-pushed the push-0f19080e branch 2 times, most recently from a175da2 to 954b901 Compare August 24, 2026 07:43

@jparise jparise left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We learned a few things from #13888 that could be helpful here:

  • The flaky tests probably needed to be @MainActor. The AppKit key translation routines want to run on the main thread.
  • We could reuse/refactor the new NSEvent creation code in KeyboardLayout instead of duplicating it.
  • Set consumedMods for Shift/Option translations to match real key events.
  • Avoid synthetic text on releases/control keys: real keyAction filters C0 text and sends key-up without text. This PR currently bypasses that, potentially changing Enter/Tab and Kitty protocol behavior.

@bo2themax

Copy link
Copy Markdown
Member Author

We learned a few things from #13888 that could be helpful here:

  • The flaky tests probably needed to be @MainActor. The AppKit key translation routines want to run on the main thread.
  • We could reuse/refactor the new NSEvent creation code in KeyboardLayout instead of duplicating it.
  • Set consumedMods for Shift/Option translations to match real key events.
  • Avoid synthetic text on releases/control keys: real keyAction filters C0 text and sends key-up without text. This PR currently bypasses that, potentially changing Enter/Tab and Kitty protocol behavior.

Thanks, will take a look at these points next time I rebase this.

@bo2themax
bo2themax marked this pull request as draft August 24, 2026 13:38
mitchellh added a commit that referenced this pull request Aug 25, 2026
…iers:) (#14009)

Follow up for #13888, and prepare for #13205.

The comments are copied from the history commit.

## AI Disclosure

The tests are updated by Claude, I cherrypicked them.
mitchellh added a commit that referenced this pull request Aug 25, 2026
Partial changes for #13205, known issues are marked as warnings.

### AI Disclosure

Claude generated these tests from linked pr, I cherrypicked and reviewed
myself.
@bo2themax
bo2themax marked this pull request as ready for review August 25, 2026 13:21
@bo2themax
bo2themax requested a review from jparise August 25, 2026 13:31
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@mitchellh
mitchellh merged commit e9ad4b1 into ghostty-org:main Aug 27, 2026
101 checks passed
@github-actions github-actions Bot added this to the 1.4.0 milestone Aug 27, 2026
@bo2themax
bo2themax deleted the push-0f19080e branch August 27, 2026 17:19
@paaloeye

paaloeye commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

IMO it's worth updating the docs. I'm happy to give it go.

You're welcome to open a pr to the website once this is merged.

@bo2themax ghostty-org/website#496

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants