summaryrefslogtreecommitdiff
path: root/src/input/key.zig
AgeCommit message (Collapse)Author
2025-10-04input: use std.Io.Writer for key encoder, new API, expose via libghosttyMitchell Hashimoto
This modernizes `KeyEncoder` to a new `std.Io.Writer`-based API. Additionally, instead of a single struct, it is now an `encode` function that takes a series of more focused options. This is more idiomatic Zig while also making it easier to expose via libghostty-vt. libghostty-vt also gains access to key encoding APIs.
2025-08-22gtk-ng: allow XKB remaps for non-writing-system keysLeah Amelia Chen
Compromise solution to #7356 XKB is naughty. It's really really naughty. I don't understand why we didn't just kill XKB with hammers during the Wayland migration and change it for something much better. I don't understand why we're content with what amounts to an OS-level software key remapper that completely jumbles information about original physical key codes in order to fake keyboard layouts, and not just let users who really want to remap keys use some sort of evdev or udev-based mapper program. In a sane system like macOS, the "c" key is always the "c" key, but it's understood to produce the Unicode character "ц" when using a Russian layout. XKB defies sanity, and just pretends that your "c" key is actually a "ц" key instead, and so when you ask for the keybind "Ctrl+C" it just shrugs in apathy (#7309). And so, we took matters into our own hands and interpreted hardware keycodes ourselves. But then, a *lot* of people have the ingrained muscle memory of swapping Escape with Caps Lock so that it is easier to hit. We respect that. In a sane system, they would use a remapper that actually makes the system think you've hit the Escape key when in reality you've hit the Caps Lock key, so in all intents and purposes to the OS and any app developer, these two just have their wires swapped. But not on Linux. Somehow this and the aforementioned case should be treated by the same key transform algorithm, which is completely diabolical. As a result, we have to settle for a compromise that truly satisfies neither party — by allowing XKB remaps for keys that don't really change depending on the layout. The Linux input stack besets all hopes and aspirations.
2025-05-24add cut/copy/paste keysJörg Thalheim
The origin of these keys are old sun keyboards. They are getting picked up by the custom (progammable) keyboard scene (see https://github.com/manna-harbour/miryoku for a popular layout). Support in ghosty is quite handy because it allows to bind copy/paste in a way that doesn't overlap with ctrl-c/ctrl-v, which can have special bindings in some terminal applications.
2025-05-11macOS: treat C-/ specially again to prevent beepMitchell Hashimoto
Fixes #7310
2025-05-09input: remove `physical_key` from the key event (all keys are physical)Mitchell Hashimoto
2025-05-09input: w3c names for keysMitchell Hashimoto
2025-05-09input: backwards compatibilityMitchell Hashimoto
2025-05-09apprt/gtk: buildMitchell Hashimoto
2025-05-09macOS: buildMitchell Hashimoto
2025-05-09apprt/glfw: buildsMitchell Hashimoto
2025-05-09input: remove translatedMitchell Hashimoto
2025-05-09input: key enum is now aligned with W3C keyboard codesMitchell Hashimoto
2025-05-07core: add context menu keyJeffrey C. Ollie
2025-04-18macOS: translation mods should never have "control"Mitchell Hashimoto
This also lets us get rid of our `C-/` special handling to prevent a system beep.
2025-03-12Lots of 0.14 changesMitchell Hashimoto
2025-01-03Fixing a few typos in the source code comments (#4529)Peter Cock
2024-12-30input: parse triggers with codepoints that map to keys as translatedMitchell Hashimoto
Fixes #4146 This makes it so that keys such as `cmd+1` and `cmd+one` are identical.
2024-12-26Update help comment for backslashLucas Crownover
2024-10-07macos: remove the ability to bind fn/globeMitchell Hashimoto
This was recently introduced a few days ago. Unfortunately, this doesn't work as expected. The "function" modifier is not actually the fn key but used by macOS to represent a variety of "functional" key presses. This breaks other bindings such as #2411. I can't find a source on the internet that reliably tells me how we can detect fn key presses, but I do find a number of sources that tell us we can't.
2024-10-07input: function is part of the binding modsMitchell Hashimoto
2024-10-05Make the function/globe key available as a modifier on macOSMitchell Hashimoto
2024-08-19core: rework binding handling to prepare for nested binding setsMitchell Hashimoto
2024-04-17input: Key.Side needs a specific backing int for use in packedMitchell Hashimoto
2024-01-21Added plus `+` keyAurélien Cibrario
2023-12-17input: translate '\t' to Key.tabMitchell Hashimoto
This allows bindings with `tab` to work properly on Linux. The issue is that in the key translation, we weren't mapping this and thought it was invalid IME input so we were ignoring it.
2023-12-15Surface: set crosshair, change event processing logic for mouse trackingChris Marchesi
This work is mainly targeted at adding the crosshair for when ctrl/super+alt is pressed. We also add this for when mouse tracking is enabled so that we show the crosshair when ctrl/super+alt+shift is pressed at the same time. I've also changed the event processing logic here because the amount of keys we have to process has greatly increased. Instead of processing each individual event, we now process the modifier state. Additionally, some refactoring has been done geared at starting to re-work the mouse for the core surface into a something stateful. My hope is that we can continue to unravel some of this from the core surface so that we can process key inputs, motion events, and anything else relevant as inputs to transitions for shape display, click behavior, etc. This commit now also moves the ctrlOrSuper handlers to respective parts in the Key hierarchy, while also adding additional helpers for other modifiers.
2023-12-13key: add TODO's for media keysTim Culverhouse
Add TODO comments in places where we need to add media keys.
2023-12-13key: add additional keypad keysTim Culverhouse
Add additional keypad keys to the encoding scheme. This allows Ghostty to report KP_HOME and it's relatives. We also always check for a keyval first, so we can report KP_7, etc as opposed to ASCII '7'.
2023-11-13macos: ignore alt key with other modifiers setMitchell Hashimoto
This enables shifted alt-prefixed keys, such as `shift+alt+.` on US standard becoming `M->`. To do this, we needed to fix a few bugs: (1) translation mods should strip alt even if other mods are set (2) AppKit translation event needs to construct new characters with the translation mods. (3) Alt-prefix handling in KeyEncoder needs to allow ASCII utf8 translations even for macOS.
2023-11-13macos: filter option in AppKit when option-as-alt setMitchell Hashimoto
Fixes #872 In #867 we fixed macos-option-as-alt, but unfortunately AppKit ALSO does some translation so some behaviors were not working correctly. Specifically, when you had macos-option-as-alt set, option+e would properly send `esc+e` to the pty but it would ALSO set the dead key state for "`" since AppKit was still translating the option key. This commit introduces a function to strip alt when necessary from the translation modifiers used at the AppKit layer, preventing this behavior.
2023-10-24macos: complete cimgui eventsMitchell Hashimoto
2023-10-15core: scroll viewport back to bottom on any key input that isn't a modMitchell Hashimoto
Fixes #619 This changes the behavior from requiring printable text to any input that isn't a modifier and also generates some data we send to the pty. If there is printable text, we also clear the selection.
2023-09-29input: fix regression with ascii mapping to a keypad keyMitchell Hashimoto
2023-09-29input: make Key ascii functions comptime-generatedMitchell Hashimoto
2023-09-29input(kitty): fix reporting of alternate keysTim Culverhouse
Fix reporting of alternate keys when using the kitty protocol. Alternate keyboard layouts were failing to report the "base layout" key. This implementation now matches kitty's output 1:1, and has some added unit tests for cyrillic characters. This also fixes a bug where a caps_lock modified key would report the shifted key as well. The protocol explicitly requires that shifted keys are only reported if the shift modifier is true.
2023-09-22apprt/embedded: if a physical key input is a keypad key, keep itMitchell Hashimoto
2023-08-17input: key must provide unshifted codepointMitchell Hashimoto
2023-08-16input: encoding should always write to the bufMitchell Hashimoto
2023-08-16input: starting to work on KeyEncoder, got ctrl sequencesMitchell Hashimoto
2023-08-14input: expand Mods size, convert everything to use itMitchell Hashimoto
2023-08-14input: unify binding-sensitive mods to a single funcMitchell Hashimoto
2023-08-13input: various more helpersMitchell Hashimoto
2023-08-11input: printable, comment on what magic indexes meanMitchell Hashimoto
2023-08-11macos: use the new self-hosted translationMitchell Hashimoto
2023-08-08Fix typosKevin Hovsäter
2023-08-07Revert "Merge pull request #244 from mitchellh/alt-as-esc"Mitchell Hashimoto
This reverts commit c139279d479682c17f63d9b57c2d56608d09d16a, reversing changes made to 4ed21047a734d7c586debe0026e3b6ea90ed1622. We do want to do this but this broke bindings.
2023-08-07key: fix wrong commentMitchell Hashimoto
2023-08-07non-macos doesn't support directional bindingsMitchell Hashimoto
2023-08-07make keyboard modifiers left/right-aware throughout coreMitchell Hashimoto
2023-06-30Update Zig (#164)Mitchell Hashimoto
* update zig * pkg/fontconfig: clean up @as * pkg/freetype,harfbuzz: clean up @as * pkg/imgui: clean up @as * pkg/macos: clean up @as * pkg/pixman,utf8proc: clean up @as * clean up @as * lots more @as cleanup * undo flatpak changes * clean up @as