From 32d4c35d29399edeb4f1da29232de1fb3faf6a52 Mon Sep 17 00:00:00 2001 From: Cameron Taylor Date: Tue, 3 Sep 2024 13:17:30 -0400 Subject: [PATCH] fix for html5 arrow keys not working on the console (#3247) --- flixel/system/debug/console/Console.hx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/flixel/system/debug/console/Console.hx b/flixel/system/debug/console/Console.hx index 638e543b84..0a01140ed8 100644 --- a/flixel/system/debug/console/Console.hx +++ b/flixel/system/debug/console/Console.hx @@ -218,6 +218,24 @@ class Console extends Window if (!history.isEmpty) setText(history.getPreviousCommand()); + #if html5 + // FlxKeyboard.preventDefaultKeys adds "preventDefault" on HTML5 + // so it ends up not fully propegating our inputs to the stage/event listeners + // we do this small work around so we don't need to mess around with lime/openfl events + // todo: support the modifier keys + case Keyboard.RIGHT: + if (FlxG.keys.preventDefaultKeys.contains(Keyboard.RIGHT)) + { + @:privateAccess + input.window_onKeyDown(RIGHT, 0); + } + case Keyboard.LEFT: + if (FlxG.keys.preventDefaultKeys.contains(Keyboard.LEFT)) + { + @:privateAccess + input.window_onKeyDown(LEFT, 0); + } + #end case Keyboard.DOWN: if (!history.isEmpty) setText(history.getNextCommand());