[Keyboard Plugin][SOLVED] How do I detect non ascii chars?

Get help using Construct 2

Post » Sun Aug 07, 2016 11:18 pm

Hi,
I have a huge problem understanding how the Keyboard plugin detects which character is typed.
In my example, I have a [TextBox] and an [Input Text Box].
I use a french keyboard with characters like 'é', 'è', 'ç', etc.

FRENCH KEYBOARD
I'm just trying to detect the character 'é' which is on the same key as the character '2' on the French keyboard.
The '2' is triggered when CAPS are on, and if not, it is the 'é' that is displayed.

STEPS TO REPRODUCE THE STRANGE BEHAVIOUR

* USING ONLY THE TEXT BOX*
When I put the focus on the Input Text Box, I can type the character 'é' without any problems inside the Input Text Box.

* USING ONLY THE TEXT BOX*
Now, I put the focus out of the Input Text Box.
I added an event on the Keyboard and the Text Box.

Every time I type something, the character is displayed in the Text Box.
So, I type the same character 'é' but I only get the character '2' and NEVER the character 'é' which is the one I'm typing. (I'm not using any CAPS on)

Here is the capx to test:
https://dl.dropboxusercontent.com/u/22785599/Html%20Projects/InconsistentKeyboardBehavior.capx

Could someone help me understand this please ?
Last edited by anthonykojima on Tue Aug 09, 2016 8:23 am, edited 1 time in total.
B
43
S
10
G
7
Posts: 183
Reputation: 10,063

Post » Mon Aug 08, 2016 2:23 am

Calling local Frenchmen @Kyatric and @Yann

Maybe those guys will know :D

~Sol
Tired of crappy file hosts that are crappy? Get DROPBOX - https://db.tt/uwjysXJF
Moderator
B
83
S
34
G
40
Posts: 3,032
Reputation: 30,474

Post » Mon Aug 08, 2016 3:57 am

The keycode gives the physical key location more or less, and the other function converts that to the character. It doesn't take into account if capslock or shift is pressed though.


Here's a way to take into account shift and capslock.
https://dl.dropboxusercontent.com/u/542 ... essed.capx
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Aug 08, 2016 9:32 am

If you attempt to display the keycode corresponding to when you are pressing "é" on your keyboard, with the Textbox out of focus you will end up with the code 50 which is the character "2".
As R0jo mentions, shift and alt status is not taken into account when pressing a key.
New to Construct ? Where to start

Image Image

Image Image

Please attach a capx to any help request or bug report !
Moderator
B
289
S
112
G
94
Posts: 7,333
Reputation: 69,293

Post » Tue Aug 09, 2016 8:20 am

Thanks a lot guys (@SoldjahBoy , @R0J0hound , @Kyatric),

Now I understand better. The Keyboard.LastKeyCode function is not used to know which exact key was typed but which "physical" key was typed.
That's why we can bind and build custom controls for the player.

Although I haven't tested yet your solution R0J0hound, because I fear the call of Javascript code as it is warned by Ashley, thank you for your solution.
I'll give it a shot.

Putting this subject at SOLVED.
B
43
S
10
G
7
Posts: 183
Reputation: 10,063


Return to How do I....?

Who is online

Users browsing this forum: David181, FacuLNF and 43 guests