Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"dead_key" button is not correctly converted to label and triggeres twice on second press (QWERTZ keyboard) #98894

Open
gitsomebit opened this issue Nov 6, 2024 · 2 comments

Comments

@gitsomebit
Copy link

gitsomebit commented Nov 6, 2024

Tested versions

  • Reproduced in 4.3 stable and 4.2 stable

System information

Windows 10 - Godot 4.3 - Compatibility - QWERTZ keyboard

Issue description

I am working on an Input remapping system and ran into an issue with the conversion from a dead_key press into a displayable character. "dead_keys" I am talking about are the keys marked red on the QWERTZ layout in the top right and left:
383262997-9e4175ce-ab36-48cb-a535-de75e55a9848

These buttons have a unique behaviour when writing, as when they are pressed, they output nothing and when pressed again, they will output depending on the next pressed button. examples for the QWERTZ layout include:

first_input text_output second_input text_output note
^ NONE ^ ^^ pressing dead character again outputs it twice
^ NONE e ê pressing compatible character second
^ NONE SPACE_BAR ^ there is no space after the ^
^ NONE w ^w non compatible characters
´ NONE ´ ´´ pressing dead character again outputs it twice
´ NONE e é pressing compatible character second
´ NONE SPACE_BAR ´ there is no space after the ´
´ NONE w ´w non compatible characters

the issue

when trying to output the label of the button with OS.get_keycode_string(event.get_key_label_with_modifiers()) the output changes for dead_keys on the second_input and to a diffrent symbol that is not printed on the key.

Steps to reproduce

create a new scene with a control node and use the _input() function:

func _input(event: InputEvent) -> void:
	if event is InputEventKey and event.is_pressed() and not event.is_echo():
		print(OS.get_keycode_string(event.get_key_label_with_modifiers()))

output for the ^ key

When pressing the ^ key repeatedly it outputs the following (first_input outputs AsciiCircum and second_input triggers input function twice with BackSlash as output):

AsciiCircum
BackSlash
BackSlash
AsciiCircum
BackSlash
BackSlash
AsciiCircum

I find this strange for two reasons:

  1. why is the input function triggered twice for the second input?
  2. why does it output BackSlash on the second input when there is no backslash on the ^ key

Meanwhile when holding down Ctrl and/or Shift and pressing the ^ key repeateadly produces the following results (not triggering the input function twice and always outputting mods+BackSlash):

Ctrl+BackSlash
Ctrl+BackSlash
Ctrl+BackSlash
Shift+BackSlash
Shift+BackSlash
Shift+BackSlash
Shift+Ctrl+BackSlash
Shift+Ctrl+BackSlash

Also holding down Alt and pressing ^ key repeateadly will not trigger the input function twice (but now alternating between Alt+AsciiCircum and Alt+BackSlash):

Alt+AsciiCircum
Alt+BackSlash
Alt+AsciiCircum
Alt+BackSlash
Alt+AsciiCircum

Holding Ctrl and Alt and pressing ^ key repeateadly always produces BackSlash:

Alt+Ctrl+BackSlash
Alt+Ctrl+BackSlash
Alt+Ctrl+BackSlash
Alt+Ctrl+BackSlash

small nitpick: why is the output Alt+Ctrl and not Ctrl+Alt (Ctrl at the beginning) for the OS.get_keycode_string(event.get_key_label_with_modifiers()) function as thats the way we say it in speech? same for Shift+Ctrl and Shift+Alt+Ctrl ?

output for the ´ key

for the ´ button something similar occurs when pressed repeatadly with alternations between ´ and BracketRight (second input triggers twice):

´
BracketRight
BracketRight
´
BracketRight
BracketRight
´

note: its just ´ as output, not QuoteRight because only QuoteLeft is valid on a US-keyboard layout.

When holding Ctrl and pressing ´ button it always outputs BracketRight:

Ctrl+BracketRight
Ctrl+BracketRight

for the rest ´ seems to behave similar with ^ as the output differs (in regards to BackSlash has become BracketRight and is also not found on the ´ key), but triggers are identical

Minimal reproduction project (MRP)

MRP: dead_key_bug.zip

@gitsomebit gitsomebit changed the title "dead_key" button is not correctly converted to label and triggeres twice on second click (QWERTZ keyboard) "dead_key" button is not correctly converted to label and triggeres twice on second press(QWERTZ keyboard) Nov 6, 2024
@gitsomebit gitsomebit changed the title "dead_key" button is not correctly converted to label and triggeres twice on second press(QWERTZ keyboard) "dead_key" button is not correctly converted to label and triggeres twice on second press (QWERTZ keyboard) Nov 6, 2024
@gitsomebit
Copy link
Author

gitsomebit commented Nov 10, 2024

I adapted the code to the following:

func _input(event: InputEvent) -> void:
	if event is InputEventKey and event.pressed and not event.is_echo():
		match event.physical_keycode:
			KEY_CTRL, KEY_SHIFT:
				pass
			_:
				print(event)
				prints(event.physical_keycode, OS.get_keycode_string(event.physical_keycode))
				prints(event.keycode, OS.get_keycode_string(event.keycode))
				prints(event.key_label, OS.get_keycode_string(event.key_label))

Now, pressing the ^ key 4 times yields the following output:

InputEventKey: keycode=92 (BackSlash), mods=none, physical=false, location=unspecified, pressed=true, echo=false
96 QuoteLeft
92 BackSlash
94 AsciiCircum
InputEventKey: keycode=92 (BackSlash), mods=none, physical=false, location=unspecified, pressed=true, echo=false
96 QuoteLeft
92 BackSlash
92 BackSlash
InputEventKey: keycode=92 (BackSlash), mods=none, physical=false, location=unspecified, pressed=true, echo=false
96 QuoteLeft
92 BackSlash
92 BackSlash
InputEventKey: keycode=92 (BackSlash), mods=none, physical=false, location=unspecified, pressed=true, echo=false
96 QuoteLeft
92 BackSlash
94 AsciiCircum
InputEventKey: keycode=92 (BackSlash), mods=none, physical=false, location=unspecified, pressed=true, echo=false
96 QuoteLeft
92 BackSlash
92 BackSlash
InputEventKey: keycode=92 (BackSlash), mods=none, physical=false, location=unspecified, pressed=true, echo=false
96 QuoteLeft
92 BackSlash
92 BackSlash

When looking at the the key_label and keycode, it seems the key_label alternates between keylabel and keycode for some reason.

@Giganzo
Copy link
Contributor

Giganzo commented Nov 22, 2024

Same as #94517

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants