Fix held keys getting stuck when opening Options

This commit is contained in:
rdbtCVS
2026-10-14 18:02:31 +01:00
parent 52975ad988
commit b6df5a91a9
3 changed files with 12 additions and 6 deletions
+6 -4
View File
@@ -8358,15 +8358,17 @@ impl ApplicationHandler for Game<'_> {
WindowEvent::KeyboardInput { event, .. } if self.screen == Screen::WorldOptions => {
self.world_options_key(&event)
}
WindowEvent::KeyboardInput { event, .. } if self.screen == Screen::Options => {
// Options consumes presses; releases still reach the bound
// gameplay mapping below, including sneak/sprint toggles.
WindowEvent::KeyboardInput { event, .. }
if self.screen == Screen::Options && event.state == ElementState::Pressed =>
{
if let Some(shortcut) = self.edit_shortcut(&event)
&& self.options_shortcut(shortcut)
{
return Ok(());
}
if event.state == ElementState::Pressed
&& let PhysicalKey::Code(key) = event.physical_key
{
if let PhysicalKey::Code(key) = event.physical_key {
self.options_key(key, event.text.as_deref())?;
}
}
+3 -2
View File
@@ -163,8 +163,9 @@ impl Game<'_> {
self.debug_key(key, KeyAction::Release);
}
}
// Physical key presses follow the key binds like the keyboard does.
let key = if matches!(self.screen, Screen::Chat | Screen::Options) {
// Text screens consume raw presses; releases follow key binds.
let typing = matches!(self.screen, Screen::Chat | Screen::Options);
let key = if typing && arg(2)? != "up" {
key
} else {
match self.settings.keys.translate(key) {
@@ -26,6 +26,9 @@ impl Game<'_> {
}
/// Open the options screens (OptionsScreen) from the title or pause menu.
pub(super) fn open_options(&mut self, from_title: bool) {
// Gameplay keys must not stay held behind the options screen, where
// bindings can also change before the physical key is released.
self.keys.clear();
self.screen = Screen::Options;
self.options_from_title = from_title;
let ui = &mut self.ui.options;