Get out Keyboard.LastKeyCode the letter

Get help using Construct 2

Post » Tue Jan 15, 2013 1:55 pm

Hello,

im trying to make a small textbox (No I cant use the given one) so I need to get the Users last pressed Letter. Its no problem to get the Keycode. Any Ideas how I could get out of the KeyCode the letter ?


To explain it a bit better and because of my english sucks:

I dont want the LasKeyCode("65") I want the letter "A".
B
15
S
6
G
6
Posts: 512
Reputation: 5,550

Post » Tue Jan 15, 2013 3:08 pm

Other than using a plugin, you could simply build a list in an array

[code]on start of layout
   local text letters = "abcdefghijklmnopqresuvwxyz"
   set codeToChar size to (256,1,1)
   repeat 26 times:
      //letters
      set codeToChar.At(65+loopindex) = tokenat(upperCase,loopindex,"")
   repeat 10 times:
      //numbers
      set codeToChar.At(48+loopindex) = loopindex
      //numpad
      set codeToChar.At(96+loopindex) = "numpad "&loopindex[/code]
      //F1 to F12
   repeat 12 times:
      set codeToChar.At(112+loopindex) = "F"&(loopindex+1)[/code]
so you can do
[code]codeToChar.At(keyboard.LastKeyCode)[/code] to get the key

You'll have to fill the other possible key more... manually though (:
Yann2013-01-15 15:11:34
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Jan 15, 2013 8:36 pm

So much work :D

I already tought about something like that, but really big thanks it will save me much time.
B
15
S
6
G
6
Posts: 512
Reputation: 5,550


Return to How do I....?

Who is online

Users browsing this forum: Callan S, getplay, Kagubro and 27 guests