Skip to content

Commit 82c4ede

Browse files
authored
Windows: Caps Lock can be a shortcut by itself (Labs › Special keys alone) (#2920)
1 parent c34078c commit 82c4ede

20 files changed

Lines changed: 173 additions & 35 deletions

File tree

‎docs/cli.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,10 @@ support this lab.
634634
Off, they are refused with `invalid-value`, and turning the toggle off puts
635635
a shortcut on one back to its default. Elsewhere one alone still needs a
636636
modifier.
637+
- On Windows with the same toggle on, `capslock`, `insert`, `home`, `end`,
638+
`pageup`, or `pagedown` may be a shortcut alone, for example
639+
`hex settings set dictation_hotkey capslock`. Hex keeps the Caps Lock
640+
presses the shortcut fires on, so the lock does not flip.
637641
- `second_dictation_hotkey` (unbound by default; `none` clears it) is a
638642
second shortcut that dictates exactly as `dictation_hotkey` does, such as a
639643
key on an external keyboard. It acts only while

‎docs/features/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2569,8 +2569,9 @@ Windows beta // x64 (Vulkan GPU) and ARM64 (CPU)
25692569
│ │ the recorder runs its own keyboard hook for them (`NumpadWatch`), so
25702570
│ │ Num Lock off records Num 8, not Up (#815)
25712571
│ ├── Menu, Pause, Scroll Lock -> may stand alone
2572-
│ ├── Insert, Home, End, Page Up, Page Down alone -> Labs › Special keys
2573-
│ │ alone; off, a saved one goes back to its default
2572+
│ ├── Caps Lock, Insert, Home, End, Page Up, Page Down alone -> Labs ›
2573+
│ │ Special keys alone; off, a saved one goes back to its default. Hex
2574+
│ │ keeps a Caps Lock press it records or fires on, so the lock never flips
25742575
│ └── Any other key -> the recorder says "Unsupported key" and starts over
25752576
├── Left Alt -> Hold or Toggle -> Capture -> Stream (GPU) -> Paste
25762577
├── Toggle's cancel shortcut (Escape by default) -> Discards a toggled recording;

‎docs/features/dictation.md‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ recorder refuses them, and a saved shortcut on one goes back to its default
124124
when settings load or the toggle turns off. On, the window's recorder takes
125125
them too (#1187). Details and checks in [labs.md](labs.md).
126126

127+
Windows with the same toggle on: Caps Lock may be a shortcut's key alone, as
128+
Insert, Home, End, Page Up, and Page Down may (`hex settings set
129+
dictation_hotkey capslock`, or press it in the window's recorder). The
130+
listener keeps every Caps Lock press the shortcut fires on, and the recorder's
131+
own hook keeps a press made in Hex's window, so the lock never flips; with
132+
other modifiers held, Caps Lock still reaches Windows. Off, the recorder
133+
shows "Add a modifier", `hex settings` refuses it, and a saved one goes back
134+
to its default. Caps Lock with a modifier needs no toggle. Implemented
135+
November 26, 2026 from a user report; not yet run on a Windows keyboard.
136+
Checks: `the_recorder_keeps_a_whole_caps_lock_press_made_in_hexs_window`
137+
(`windows/input/chord.rs`) and
138+
`pause_and_scroll_lock_stand_alone_but_numpad_keys_need_a_modifier`
139+
(`windows/input.rs`).
140+
127141
Linux and macOS with Labs › § key alone on (`labs.section_key_alone`,
128142
off by default; issue 1050): the ISO section key, left of 1, may be a
129143
shortcut with no modifier. On Linux the window's recorder takes § pressed

‎docs/features/labs.md‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ Feature Pane Toggle (settings.json, hex settings) On: what it doe
162162
├── Sort and filter models no labs.picker_sort_filter the Local transcription picker sorts by recommendation, size, or name and can show only models for the saved language (#645)
163163
├── Model test details no labs.benchmark_details picker rows show raw WER/CER (lower is better), language, dataset, source, and conditions; incomparable "Most accurate" badges drop (#647)
164164
├── Parakeet Ultra no labs.parakeet_ultra the picker offers Moondream's Parakeet Ultra (pinned Q8_0, CC BY 4.0) with a details view; stays on while it dictates (#648)
165-
├── Special keys alone no labs.standalone_special_keys (Linux, Windows) Linux: Menu, Pause, Scroll Lock may be a shortcut's key, alone or with modifiers (#767); Windows: Insert, Home, End, Page Up, Page Down may stand alone (#794)
165+
├── Special keys alone no labs.standalone_special_keys (Linux, Windows) Linux: Menu, Pause, Scroll Lock may be a shortcut's key, alone or with modifiers (#767); Windows: Caps Lock, Insert, Home, End, Page Up, Page Down may stand alone (#794)
166166
├── § key alone no labs.section_key_alone (Linux, macOS) the key left of 1 on ISO keyboards, § or a dead key such as ^, may be a shortcut with no modifier (#1050)
167167
├── Microphone key alone no labs.microphone_key (macOS) the microphone (dictation) key in a laptop keyboard's top row, always reported as Fn with key code 176, may be a shortcut with no modifier (#181)
168168
├── Dictation stats no labs.history_stats History's Stats button opens a summary of retained dictations, with headline tiles, a typing-speed slider and time saved, the busiest-hour strip, a daily chart, app and Output bars, and Output time; an owner-only daily rollup (counts only, no text or app names) outlives retention, so the dialog also charts a 53-week heatmap and its headline totals cover all time; Clear all history deletes the rollup even with no entries; hex history stats prints it (#790)
@@ -2496,8 +2496,16 @@ hex settings set dictation_hotkey menu // labs.special-keys
24962496
│ └── Wayland portal -> preferred trigger Menu, Pause, Scroll_Lock
24972497
├── Toggle off -> "menu needs Labs › Special keys alone: hex labs on special-keys"
24982498
├── Windows -> Menu, Pause, Scroll Lock always allowed, alone too; the toggle
2499-
│ instead lets Insert, Home, End, Page Up, Page Down stand alone ("home alone
2500-
│ needs Labs › Special keys alone" while off), and off puts a saved one back
2499+
│ instead lets Caps Lock, Insert, Home, End, Page Up, Page Down stand alone
2500+
│ ("home alone needs Labs › Special keys alone" while off), and off puts a
2501+
│ saved one back
2502+
│ └── Caps Lock (`capslock`) -> the recorder's hook keeps a press made in
2503+
│ Hex's window, and a shortcut keeps every press it fires on, so the lock
2504+
│ never flips; Caps Lock with other modifiers held still reaches Windows.
2505+
│ Checks: `the_recorder_keeps_a_whole_caps_lock_press_made_in_hexs_window`
2506+
│ (`windows/input/chord.rs`),
2507+
│ `caps_lock_is_named_in_any_spelling_and_alone_is_a_windows_special_key`
2508+
│ (`app_settings/shortcut_repair.rs`); no run on a Windows keyboard
25012509
├── macOS -> no toggle; a bare one still needs a modifier, as before
25022510
├── Window recorder (Linux) -> records them, alone too, while on (#1187);
25032511
│ refuses them while off ("Add a modifier")

‎site/src/labs.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,7 @@
409409
"windows",
410410
"linux"
411411
],
412-
"summary": "Use a special key alone as a shortcut: Insert, Home, End, Page Up, or Page Down on Windows, and Menu, Pause, or Scroll Lock on Linux",
412+
"summary": "Use a special key alone as a shortcut: Caps Lock, Insert, Home, End, Page Up, or Page Down on Windows, and Menu, Pause, or Scroll Lock on Linux",
413413
"title": "Special keys alone"
414414
},
415415
{

‎src/app_settings/hotkeys.rs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ pub(super) fn key_label(name: &str) -> String {
488488
if shortcut_repair::is_scroll_lock(name) {
489489
return "Scroll Lock".into();
490490
}
491+
if HotkeyKey::caps_lock_name(name) {
492+
return "Caps Lock".into();
493+
}
491494
// `section`, as `hex settings` may name the § key.
492495
if name.eq_ignore_ascii_case("section") {
493496
return "§".into();

‎src/app_settings/shortcut_repair.rs‎

Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
//! Shortcut keys a Labs feature allows, and the repair that puts a saved
22
//! shortcut on one back while the feature is off: mouse buttons (Labs ›
33
//! Mouse shortcuts, macOS), Menu, Pause, or Scroll Lock (Labs › Special
4-
//! keys alone, Linux), the ISO section key (Labs › § key alone, Linux
4+
//! keys alone, Linux), Caps Lock or a navigation key alone (the same Lab,
5+
//! Windows), the ISO section key (Labs › § key alone, Linux
56
//! and macOS), the microphone key (Labs › Microphone key alone, macOS),
67
//! shortcuts without a key (Labs › Double-tap Option, Command, or
78
//! Globe, macOS), and the persisted double-tap mode those need.
@@ -64,6 +65,21 @@ impl HotkeyKey {
6465
)
6566
}
6667

68+
/// Caps Lock, which Labs › Special keys alone lets a Windows shortcut
69+
/// use alone. Hex keeps the press, so the lock never flips.
70+
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
71+
pub fn is_caps_lock(&self) -> bool {
72+
!self.is_mouse() && Self::caps_lock_name(&self.label)
73+
}
74+
75+
/// Whether `name` names Caps Lock: `capslock`, `caps_lock`, or
76+
/// `Caps Lock`.
77+
pub fn caps_lock_name(name: &str) -> bool {
78+
name.trim()
79+
.replace([' ', '_'], "")
80+
.eq_ignore_ascii_case("capslock")
81+
}
82+
6783
/// Whether `label` names a function key (`F1`–`F20`, any case).
6884
pub fn is_function_name(label: &str) -> bool {
6985
label
@@ -80,6 +96,14 @@ impl HotkeyBinding {
8096
self.modifiers.is_empty() && self.key.as_ref().is_some_and(HotkeyKey::is_navigation)
8197
}
8298

99+
/// Caps Lock or a navigation key alone: the keys a Windows shortcut may
100+
/// use by themselves only with Labs › Special keys alone.
101+
#[cfg_attr(not(target_os = "windows"), allow(dead_code))]
102+
pub fn is_lone_windows_special_key(&self) -> bool {
103+
self.is_lone_navigation_key()
104+
|| (self.modifiers.is_empty() && self.key.as_ref().is_some_and(HotkeyKey::is_caps_lock))
105+
}
106+
83107
/// The § key alone (`HotkeyKey::is_section`).
84108
pub fn is_lone_section_key(&self) -> bool {
85109
self.modifiers.is_empty() && self.key.as_ref().is_some_and(HotkeyKey::is_section)
@@ -102,7 +126,7 @@ pub(super) fn is_scroll_lock(name: &str) -> bool {
102126
impl AppSettings {
103127
/// Whether Labs › Special keys alone is on: on Linux a shortcut may use
104128
/// Menu, Pause, or Scroll Lock; on Windows, which takes those anyway,
105-
/// a navigation key alone.
129+
/// Caps Lock or a navigation key alone.
106130
pub fn special_keys_allowed(&self) -> bool {
107131
cfg!(any(target_os = "linux", target_os = "windows"))
108132
&& self.labs.standalone_special_keys
@@ -208,12 +232,12 @@ impl AppSettings {
208232
"reset Menu, Pause, and Scroll Lock shortcuts: Labs › Special keys alone is off"
209233
);
210234
}
211-
// Windows: a navigation key alone needs the toggle.
235+
// Windows: Caps Lock or a navigation key alone needs the toggle.
212236
if cfg!(target_os = "windows")
213-
&& self.reset_shortcuts(HotkeyBinding::is_lone_navigation_key)
237+
&& self.reset_shortcuts(HotkeyBinding::is_lone_windows_special_key)
214238
{
215239
tracing::info!(
216-
"reset navigation-key shortcuts without a modifier: Labs › Special keys alone is off"
240+
"reset Caps Lock and navigation-key shortcuts without a modifier: Labs › Special keys alone is off"
217241
);
218242
}
219243
}
@@ -333,6 +357,26 @@ mod tests {
333357
);
334358
}
335359

360+
#[test]
361+
fn caps_lock_is_named_in_any_spelling_and_alone_is_a_windows_special_key() {
362+
for name in ["capslock", "caps_lock", "Caps Lock", " caps lock "] {
363+
assert!(HotkeyKey::caps_lock_name(name), "{name}");
364+
assert_eq!(HotkeyKey::named(name).label, "Caps Lock");
365+
}
366+
assert!(!HotkeyKey::caps_lock_name("scroll lock"));
367+
let caps_lock = |modifiers: HotkeyModifiers| HotkeyBinding {
368+
modifiers,
369+
key: Some(HotkeyKey::named("capslock")),
370+
};
371+
assert!(caps_lock(Default::default()).is_lone_windows_special_key());
372+
let with_control = HotkeyModifiers {
373+
control: Some(crate::app_settings::ModifierSide::Either),
374+
..Default::default()
375+
};
376+
assert!(!caps_lock(with_control).is_lone_windows_special_key());
377+
assert!(!menu().is_lone_windows_special_key());
378+
}
379+
336380
#[test]
337381
fn menu_pause_and_scroll_lock_are_the_special_keys() {
338382
for name in ["menu", "Pause", "scrolllock", "scroll_lock", "Scroll Lock"] {

‎src/app_settings/slots.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,9 +419,10 @@ pub fn check_shortcut_policy(
419419
{
420420
return Err(ShortcutRefusal::MicrophoneKeyOnScreenshot);
421421
}
422-
// Windows: a navigation key alone needs Labs › Special keys alone.
422+
// Windows: Caps Lock or a navigation key alone needs Labs › Special keys
423+
// alone.
423424
if cfg!(target_os = "windows")
424-
&& binding.is_lone_navigation_key()
425+
&& binding.is_lone_windows_special_key()
425426
&& !settings.special_keys_allowed()
426427
{
427428
let key_name = binding

‎src/control/settings/hotkeys.rs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,14 +143,16 @@ pub fn parse_hotkey(
143143
if binding.is_bare_primary_click() {
144144
return Err("mouse1 (left click) needs a modifier, such as option+mouse1".into());
145145
}
146-
// Menu, Pause, and Scroll Lock alone, and on Windows the navigation
147-
// keys alone, are checked against their Labs toggle when set
148-
// (`special_key_refusal`).
146+
// Menu, Pause, and Scroll Lock alone, and on Windows Caps Lock and
147+
// the navigation keys alone, are checked against their Labs toggle
148+
// when set (`special_key_refusal`).
149149
if modifiers.is_empty()
150150
&& !HotkeyKey::is_function_name(&key.label)
151151
&& !key.is_mouse()
152152
&& !HotkeyKey::special_name(&key.label)
153-
&& !(cfg!(target_os = "windows") && HotkeyKey::navigation_name(&key.label))
153+
&& !(cfg!(target_os = "windows")
154+
&& (HotkeyKey::navigation_name(&key.label)
155+
|| HotkeyKey::caps_lock_name(&key.label)))
154156
&& !(cfg!(any(target_os = "linux", target_os = "macos")) && key.is_section())
155157
&& !(cfg!(target_os = "macos") && key.is_microphone())
156158
{

‎src/desktop/i18n.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,7 @@ mod tests {
886886
];
887887
for english in [
888888
"Use Menu, Pause, or Scroll Lock as a shortcut by itself, such as Caps Lock remapped to Menu",
889-
"Use Insert, Home, End, Page Up, or Page Down as a shortcut by itself",
889+
"Use Caps Lock, Insert, Home, End, Page Up, or Page Down as a shortcut by itself",
890890
] {
891891
let translations = table
892892
.get(english)

0 commit comments

Comments
 (0)