Detecting all keys in windowed screen

Just starting out? Need help? Post your questions and find answers here.
User avatar
Erich
User
User
Posts: 49
Joined: Thu Sep 30, 2010 9:21 pm

Detecting all keys in windowed screen

Post by Erich »

Hi! :D

I need to know whether it's possible to detect all keys that are pressed or released in a screen opened by OpenWindowedScreen, no matter what keyboard layout. Basically I need the same functionality as in a CanvasGadget with keyboard input enabled. This Gadget returns codes like 65362 for up-arrow or 65362 for pause.

But ExamineKeyboard() doesn't work for me. Right now, on my linux machine, PB 4.61 does not trigger anything (tested KeyboardReleased until 1024) when I set the keyboard to German and press a letter like ä. It doesn't matter whether I set KeyboardMode(#PB_Keyboard_International) or KeyboardMode(#PB_Keyboard_Qwerty). I don't care how raw the keycodes are, as long as they are cross-platform and can be decoded somehow. I need to detect every key on the keyboard including all function keys, shift, alt, etc.

Is there any way to do this cross-platform within a windowed screen? If not it's a show-stopper and I have to revert back to drawing on a CanvasGadget, but that's too slow.
"I have never let my schooling interfere with my education." - Mark Twain
User avatar
Erich
User
User
Posts: 49
Joined: Thu Sep 30, 2010 9:21 pm

Re: Detecting all keys in windowed screen

Post by Erich »

Sorry to bump my own thread, but even just knowing that it's not possible would be very useful to me. In my tests, TAB doesn't work at all, and no international characters when the keyboard is set to something else than QWERTY. Normal characters work with the international setting, e.g. German QWERTZ keyboard setting results in Z when pressing the US key Y as expected. But ö,ä,ü,ß,' don't work.

Here are the key pushed codes I've found so far: 273 up-arrow, 276 left arrow, 274 down arrow, 275 right arrow, 303 shift-r, 304 shift-l, 306 ctrl-l, 308 alt-l, 307 alt-r, 309 altgr, 305 ctrl-r, 280 page up, 281 page down, 277 insert, 278 home, 279 end, 282-293 f1-f12, 19 pause. ESC, TAB, RETURN, DELETE are returned as ASCII codes like the letters.

Does anybody know where the codes above 255 come from and what they represent? I've been looking for key scan codes but didn't find these specific ones anywhere. The closest list I've found is, surprisingly, one for the Rasperry PI but it's not an exact match. Are those codes keyboard-dependent?

Is there no way to get key PUSHED codes for TAB and international characters if the keyboard has an international setting? Is this a bug on Linux?
"I have never let my schooling interfere with my education." - Mark Twain
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: Detecting all keys in windowed screen

Post by IdeasVacuum »

Hello Erich

The link below is probably not the answer, but it could lead to a solution. If what you want can be done, then the likes of JHPJHP will figure it out:

http://www.purebasic.fr/english/viewtop ... &t=60775&p
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
Erich
User
User
Posts: 49
Joined: Thu Sep 30, 2010 9:21 pm

Re: Detecting all keys in windowed screen

Post by Erich »

For now I have resorted to using KeyboardReleased in combination with KeyboardInkey character-like keys but it means that there can be no key repeat after a key repeat interval, something which almost every normal OS text handling offers. :|

But I'm also worried about the codes themselves. What do codes > 255 represent, where do they come from? Can they differ from one keyboard hardware to another or not?
"I have never let my schooling interfere with my education." - Mark Twain
Post Reply