[PR #3564] [MERGED] Key binds: a moved key no longer keeps its default action #5055

Closed
opened 2026-11-03 05:09:55 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/3564
Author: @d3grando
Created: 10/29/2026
Status: ✅ Merged
Merged: 10/29/2026
Merged by: @levzzz5154

Base: main ← Head: fix-3158


📝 Commits (1)

  • b2a5abb Key binds: a moved key no longer keeps its default action

📊 Changes

1 file changed (+48 additions, -13 deletions)

View changed files

📝 crates/horizon-client-input/src/keybinds.rs (+48 -13)

📄 Description

🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves.

Fixes #3158

What and why

After a key bind changed, the old key kept its old action. Two cases from the report:

  • With key.hotbar.1 moved from 1 to Q, pressing 1 still selected slot 1.
  • With the inventory on A and strafe left on E, A still strafed left.

KeyBinds::translate_all turns a pressed key into the default keys of every mapping bound to it, so the game's code (written against vanilla defaults) follows the player's bindings. A key whose default mapping moved elsewhere is meant to become inert.

The translation also followed the debug mappings. Their defaults are the gameplay keys themselves: key.debug.reloadChunk is A, dumpDynamicTextures is S, profilingChart is 1, fpsCharts is 2, and so on. So after key.hotbar.1 moved off 1, the 1 key was still "bound" to key.debug.profilingChart, whose default is 1. It translated back to Digit1 and selected slot 1. A did the same through F3+A's default, and S kept walking back after key.back moved.

The debug keys only act with F3 held (KeyboardHandler.handleDebugKeys), and game/debug_keys.rs already handles them from the physical key and the binding. Translation now leaves them out: translated_mappings and default_moved skip the debug category.

I also checked the code that reads the raw key instead of the translated one. inventory_hotkey and the menu's hotbar keys get the translated key, and the screen-close keys only gate the F3 combos. The one raw path left is the creative search tab, where the window's own key event reaches search_tab_hotbar_key before translation. I didn't change it here: horizon-ctl can't send a raw window key, so I couldn't check it in game.

Vanilla reference

  • KeyMapping.set / KeyMapping.click: only the mappings bound to a key are pressed. A key with no mapping does nothing.
  • KeyboardHandler.keyPress → handleDebugKeys (and handleChunkDebugKeys): the debug mappings (Options.keyDebugReloadChunk, …) act only while keyDebugModifier (F3) is down. They never stand in for a gameplay mapping.

No parity harness covers key bindings. The unit test is below.

Test

cargo test -p horizon-client-input --lib a_moved_key_keeps_no_default_action covers these cases:

  • hotbar.1 on Q: 1 does nothing, and Q is drop plus slot 1;
  • inventory on A and left on E: A only opens the inventory, and E strafes;
  • back on Down: S does nothing;
  • unmoved keys still act, and a moved debug key changes nothing.

Without the fix (the debug filter disabled):

test keybinds::tests::a_moved_key_keeps_no_default_action ... FAILED
assertion `left == right` failed
  left: [Ok(Digit1)]
 right: []

With it:

test keybinds::tests::a_moved_key_keeps_no_default_action ... ok
test result: ok. 47 passed; 0 failed   (cargo test -p horizon-client-input --lib)

In game (horizon-ctl, survival world): key.hotbar.1 on Q, key.back on the down arrow, slot 3 selected; press 1, then hold S for 20 ticks.

Before (origin/main b19b4e92d):

hotbar.1 on Q, slot 3 selected, pressed 1: selected slot 1
key.back on Down, held S for 20 ticks: x z 211.50 533.50 -> 211.50 525.30
FAIL: 1 still selects slot 1
FAIL: S still walks back

After (this branch, before rebasing onto current main; the rebase changed no key-handling code):

hotbar.1 on Q, slot 3 selected, pressed 1: selected slot 3
key.back on Down, held S for 20 ticks: x z 216.50 524.50 -> 216.50 524.50
PASS

Also on this branch: holding Down walks back, 2 still selects slot 2, F3+G still toggles chunk borders, and with hotbar.1 on Z, Z selects slot 1 while 1 does nothing.

Self-check

tools/pr_ready.py doesn't run on Windows (parity.py uses signal.SIGHUP), so I ran these instead:

  • cargo fmt --all -- --check: ok
  • cargo clippy -p horizon-client-input --all-targets -- -D warnings: ok
  • cargo clippy -p horizon-client --features mods --all-targets -- -D warnings: ok
  • cargo test -p horizon-client-input --lib: 47 passed
  • cargo build --profile fast -p horizon-client --features mods --bins, then the in-game check above

In-game evidence

I took screenshots of the hotbar after pressing 1, with slot 3 (an apple) selected and key.hotbar.1 on Q. On origin/main the selection jumped to slot 1 (a sword). On this branch it stays on slot 3.

🤖 Generated with Claude Code


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/horizon-rust/horizon/pull/3564 **Author:** [@d3grando](https://github.com/d3grando) **Created:** 10/29/2026 **Status:** ✅ Merged **Merged:** 10/29/2026 **Merged by:** [@levzzz5154](https://github.com/levzzz5154) **Base:** `main` ← **Head:** `fix-3158` --- ### 📝 Commits (1) - [`b2a5abb`](https://github.com/horizon-rust/horizon/commit/b2a5abb885a05faa2fb3d91cf61cac776cbf07ab) Key binds: a moved key no longer keeps its default action ### 📊 Changes **1 file changed** (+48 additions, -13 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client-input/src/keybinds.rs` (+48 -13) </details> ### 📄 Description > 🤖 Opened by d3grando's AI agent (Claude Code, Claude Opus 5.5), not by d3grando themselves. Fixes #3158 ## What and why After a key bind changed, the old key kept its old action. Two cases from the report: - With `key.hotbar.1` moved from 1 to Q, pressing 1 still selected slot 1. - With the inventory on A and strafe left on E, A still strafed left. `KeyBinds::translate_all` turns a pressed key into the default keys of every mapping bound to it, so the game's code (written against vanilla defaults) follows the player's bindings. A key whose default mapping moved elsewhere is meant to become inert. The translation also followed the **debug** mappings. Their defaults are the gameplay keys themselves: `key.debug.reloadChunk` is A, `dumpDynamicTextures` is S, `profilingChart` is 1, `fpsCharts` is 2, and so on. So after `key.hotbar.1` moved off 1, the 1 key was still "bound" to `key.debug.profilingChart`, whose default is 1. It translated back to `Digit1` and selected slot 1. A did the same through F3+A's default, and S kept walking back after `key.back` moved. The debug keys only act with F3 held (`KeyboardHandler.handleDebugKeys`), and `game/debug_keys.rs` already handles them from the physical key and the binding. Translation now leaves them out: `translated_mappings` and `default_moved` skip the `debug` category. I also checked the code that reads the raw key instead of the translated one. `inventory_hotkey` and the menu's hotbar keys get the translated key, and the screen-close keys only gate the F3 combos. The one raw path left is the creative search tab, where the window's own key event reaches `search_tab_hotbar_key` before translation. I didn't change it here: `horizon-ctl` can't send a raw window key, so I couldn't check it in game. ## Vanilla reference - `KeyMapping.set` / `KeyMapping.click`: only the mappings bound to a key are pressed. A key with no mapping does nothing. - `KeyboardHandler.keyPress` → `handleDebugKeys` (and `handleChunkDebugKeys`): the debug mappings (`Options.keyDebugReloadChunk`, …) act only while `keyDebugModifier` (F3) is down. They never stand in for a gameplay mapping. No parity harness covers key bindings. The unit test is below. ## Test `cargo test -p horizon-client-input --lib a_moved_key_keeps_no_default_action` covers these cases: - hotbar.1 on Q: 1 does nothing, and Q is drop plus slot 1; - inventory on A and left on E: A only opens the inventory, and E strafes; - back on Down: S does nothing; - unmoved keys still act, and a moved debug key changes nothing. Without the fix (the debug filter disabled): ``` test keybinds::tests::a_moved_key_keeps_no_default_action ... FAILED assertion `left == right` failed left: [Ok(Digit1)] right: [] ``` With it: ``` test keybinds::tests::a_moved_key_keeps_no_default_action ... ok test result: ok. 47 passed; 0 failed (cargo test -p horizon-client-input --lib) ``` **In game** (`horizon-ctl`, survival world): `key.hotbar.1` on Q, `key.back` on the down arrow, slot 3 selected; press 1, then hold S for 20 ticks. Before (origin/main b19b4e92d): ``` hotbar.1 on Q, slot 3 selected, pressed 1: selected slot 1 key.back on Down, held S for 20 ticks: x z 211.50 533.50 -> 211.50 525.30 FAIL: 1 still selects slot 1 FAIL: S still walks back ``` After (this branch, before rebasing onto current main; the rebase changed no key-handling code): ``` hotbar.1 on Q, slot 3 selected, pressed 1: selected slot 3 key.back on Down, held S for 20 ticks: x z 216.50 524.50 -> 216.50 524.50 PASS ``` Also on this branch: holding Down walks back, 2 still selects slot 2, F3+G still toggles chunk borders, and with hotbar.1 on Z, Z selects slot 1 while 1 does nothing. ## Self-check `tools/pr_ready.py` doesn't run on Windows (`parity.py` uses `signal.SIGHUP`), so I ran these instead: - `cargo fmt --all -- --check`: ok - `cargo clippy -p horizon-client-input --all-targets -- -D warnings`: ok - `cargo clippy -p horizon-client --features mods --all-targets -- -D warnings`: ok - `cargo test -p horizon-client-input --lib`: 47 passed - `cargo build --profile fast -p horizon-client --features mods --bins`, then the in-game check above ## In-game evidence I took screenshots of the hotbar after pressing 1, with slot 3 (an apple) selected and `key.hotbar.1` on Q. On origin/main the selection jumped to slot 1 (a sword). On this branch it stays on slot 3. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-03 05:09:55 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
horizon-rust/horizon#5055
No description provided.