This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
+1 vote

Hello guys :)

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)
        else:
            character = char(event.scancode).to_lower()
        print(character)

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.

in Engine by (16 points)

1 Answer

+1 vote
Best answer

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.

by (29,510 points)
selected by

Thanks, Zylann, unicode worked!!!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.