how to detect a keypress of the ~ (or `) key in gui code?

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

how to detect a keypress of the ~ (or `) key in gui code?

Post by Komag »

So I'm experimenting with John's Quick Action Bar code a bit, and I want to have opening the console (by hitting the tilde ~ also known as the backtick ` key) be another control that toggles the quick bar on and off (so when I type stuff in the console it will stop triggering actions on the quickbar due to the hot keys!)

Anyway, I can't seem to figure out how to address the ~ key. When I just hit it, NOTHING types into the code window. If I test with some regular letter like q, that works for the test. If I hold Shift to get a ~ (instead of a `) then it will at least type into the window, but it doesn't work when testing the code, no results, not even if I hold Shift during the test. It's like the ` key doesn't exist!

In my grimrock.cfg I have the console on and see that the key is called 192, but that didn't work either (neither in quotes nor out of quotes).

Am I doing something wrong? Or is this just impossible? :?:
Finished Dungeons - complete mods to play
User avatar
petri
Posts: 1917
Joined: Thu Mar 01, 2012 4:58 pm
Location: Finland

Re: how to detect a keypress of the ~ (or `) key in gui code

Post by petri »

You could try copy-pasting ~ from external text editor to dungeon editor. It's also likely that the gui system does not support "raw keys" like this. If that is the case then it's probably impossible to get this working...
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: how to detect a keypress of the ~ (or `) key in gui code

Post by Komag »

I can type a ~ but not a `, even copy paste just pastes nothing, very weird! I guess it's impossible :shock:
Finished Dungeons - complete mods to play
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: how to detect a keypress of the ~ (or `) key in gui code

Post by JohnWordsworth »

You might be able to do...

local c = string.char(65);

But replace 65 with the ASCII code for the key you want. And then use that value in the g.isKeyDown() method. (Typed on my mobile, so function names might be wrong, but the idea is that the GUI context might recognise all ASCII characters from the keyboard, even non-printable ones).
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Komag
Posts: 3659
Joined: Sat Jul 28, 2012 4:55 pm
Location: Boston, USA

Re: how to detect a keypress of the ~ (or `) key in gui code

Post by Komag »

Interesting, worth a shot
Finished Dungeons - complete mods to play
Post Reply