Special character (with shift key) not working on Windows 10

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Keyikedalube Ndang

Hello guys :slight_smile:

I am working on a typing speed game for my final semester college project.
My primary system is Debian. However, I am testing my game on Windows 10 too just to make sure everything works fine.

Here’s a problem I am currently facing- special characters with shift key combination is not working on Windows 10.
Those characters include <, >, :, ", #, @, and so on… I tried switching the keyboard layout to US QWERTY but no help at all.

Below is a code snippet I use to process key input:

func _input(event):
if event is InputEventKey:
	if event.is_pressed():
		var character
		if event.shift:
			character = char(event.scancode)
			character = char(event.scancode).to_lower()

The above code works fine on my Debian system. No issue. Special characters are printed
But I don’t understand why it’s not working on Windows.

:bust_in_silhouette: Reply From: Zylann

You should not use scancode for processing text, this is the key you pressed. The OS may do a series of transformations to get the actual text the user entered, so Godot exposes another property called unicode which will contain the resulting character.

Thanks, Zylann, unicode worked!!!

Keyikedalube Ndang | 2019-02-27 02:03