[PR #447] [MERGED] Holding the drop key keeps dropping, in game and in menus #2571

Closed
opened 2026-11-02 15:57:17 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/horizon-rust/horizon/pull/447
Author: @ludovic111
Created: 10/16/2026
Status: ✅ Merged
Merged: 10/16/2026
Merged by: @ludovic111

Base: main ← Head: fix/drop-key-repeat


📝 Commits (1)

  • 93ea338 Holding the drop key keeps dropping, in game and in menus

📊 Changes

3 files changed (+17 additions, -8 deletions)

View changed files

📝 crates/horizon-client/src/bin/horizon-ctl/commands.rs (+2 -2)
📝 crates/horizon-client/src/game.rs (+4 -1)
📝 crates/horizon-client/src/game/control.rs (+11 -5)

📄 Description

Fixes #443

What vanilla does

In 26.3 KeyboardHandler.keyPress gets SDL key repeats as InputConstants.REPEAT (-1) and treats them like a press. With a screen open, the repeat goes to Screen.keyPressed: AbstractContainerScreen.keyPressed throws the hovered slot's item (ContainerInput.THROW, Ctrl = the whole stack), and CreativeModeInventoryScreen.slotClicked throws a creative tab item (1, or a max stack with Ctrl). Without a screen, the repeat reaches KeyMapping.click, and Minecraft.handleKeybinds drops the held item once per click (gameMode.dropItem). So holding Q keeps dropping at the OS key-repeat rate.

What was wrong

Game::mapped_key threw every key repeat away before key_pressed.

Fix

  • key.drop's repeats now go through to key_pressed, which already handles Q in game, over an inventory or container slot, and over a creative tab slot (Ctrl too).
  • Other keys keep ignoring repeats as before. Vanilla also repeats them (hotbar digits, F, the inventory key…). Letting those through is a separate behaviour change, so this PR leaves it for a follow-up.
  • horizon-ctl key KEY repeat sends one auto-repeat, so scripts can hold a key the way the OS does.

Verified in game (offscreen, control socket, Mac mini)

  • Playing, survival: 64 cobblestone in hand; key q down + 5 × key q repeat → 58 left (6 drops).
  • Survival inventory, cursor over the stack: q down + 3 repeats → 58 → 54. Ctrl+Q + repeat drops the stack, and the repeat over the now-empty slot does nothing.
  • Creative, Building Blocks tab, cursor over a spruce door: Q + 4 repeats → 5 doors on the ground; Ctrl+Q + 1 repeat → 2 × 64 more (133 in total).

Self-check

  • cargo fmt --check, cargo clippy -p horizon-client --all-targets -- -D warnings: clean.
  • horizon-client tests and the parity harnesses run once on an integration branch together with the other rdbt fixes (#446, …); the results are in the thread's report.

🤖 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/447 **Author:** [@ludovic111](https://github.com/ludovic111) **Created:** 10/16/2026 **Status:** ✅ Merged **Merged:** 10/16/2026 **Merged by:** [@ludovic111](https://github.com/ludovic111) **Base:** `main` ← **Head:** `fix/drop-key-repeat` --- ### 📝 Commits (1) - [`93ea338`](https://github.com/horizon-rust/horizon/commit/93ea338bfde8dcee140aad9944e83dac4479a644) Holding the drop key keeps dropping, in game and in menus ### 📊 Changes **3 files changed** (+17 additions, -8 deletions) <details> <summary>View changed files</summary> 📝 `crates/horizon-client/src/bin/horizon-ctl/commands.rs` (+2 -2) 📝 `crates/horizon-client/src/game.rs` (+4 -1) 📝 `crates/horizon-client/src/game/control.rs` (+11 -5) </details> ### 📄 Description Fixes #443 ## What vanilla does In 26.3 `KeyboardHandler.keyPress` gets SDL key repeats as `InputConstants.REPEAT` (-1) and treats them like a press. With a screen open, the repeat goes to `Screen.keyPressed`: `AbstractContainerScreen.keyPressed` throws the hovered slot's item (`ContainerInput.THROW`, Ctrl = the whole stack), and `CreativeModeInventoryScreen.slotClicked` throws a creative tab item (1, or a max stack with Ctrl). Without a screen, the repeat reaches `KeyMapping.click`, and `Minecraft.handleKeybinds` drops the held item once per click (`gameMode.dropItem`). So holding Q keeps dropping at the OS key-repeat rate. ## What was wrong `Game::mapped_key` threw every key repeat away before `key_pressed`. ## Fix - key.drop's repeats now go through to `key_pressed`, which already handles Q in game, over an inventory or container slot, and over a creative tab slot (Ctrl too). - Other keys keep ignoring repeats as before. Vanilla also repeats them (hotbar digits, F, the inventory key…). Letting those through is a separate behaviour change, so this PR leaves it for a follow-up. - `horizon-ctl key KEY repeat` sends one auto-repeat, so scripts can hold a key the way the OS does. ## Verified in game (offscreen, control socket, Mac mini) - Playing, survival: 64 cobblestone in hand; `key q down` + 5 × `key q repeat` → 58 left (6 drops). - Survival inventory, cursor over the stack: `q down` + 3 repeats → 58 → 54. Ctrl+Q + repeat drops the stack, and the repeat over the now-empty slot does nothing. - Creative, Building Blocks tab, cursor over a spruce door: Q + 4 repeats → 5 doors on the ground; Ctrl+Q + 1 repeat → 2 × 64 more (133 in total). ## Self-check - `cargo fmt --check`, `cargo clippy -p horizon-client --all-targets -- -D warnings`: clean. - horizon-client tests and the parity harnesses run once on an integration branch together with the other rdbt fixes (#446, …); the results are in the thread's report. 🤖 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-02 15:57:17 +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#2571
No description provided.