Firing on Modifier Key Keypresses

Post Reply
kkerwin1
Posts: 22
Joined: Tue Apr 20, 2010 7:37 am

Firing on Modifier Key Keypresses

Post by kkerwin1 »

I'd like to have a little window that displays keybindings for my various abilities. I'd like for the window to update, based on which modifier key I have pressed (CTRL, ALT, SHIFT, etc). This is similar to the action bar in WoW or EQ2 that updates based on which modifier key is currently pressed.

Currently, I can see no way to have a keybinding based on just a modifier key. If it's not possible because of, say, having a CTRL keybinding interfere with a CTRL-A keybinding, then maybe events can be created that would enable us to track when a modifier key is depressed or released.

User avatar
kevutian
Posts: 217
Joined: Fri Aug 20, 2010 8:18 pm
Location: United Kingdom
Contact:

Re: Firing on Modifier Key Keypresses

Post by kevutian »

Yeah. This would actually be a great thing to have, but as you suspect, is currently not possible.

It's hardly my field, though it may be possible that QT can raise an event dependent on the state of a modifier key.

Something for the request thread, perhaps?

User avatar
Calixa
Posts: 25
Joined: Sat Nov 20, 2010 5:51 pm
Location: Lusternia

Re: Firing on Modifier Key Keypresses

Post by Calixa »

Key state is not accessible to my knowledge, but I don't know enough about QT.

Having a similar project in mind, the best compromise I have so far is to use toggle keys rather than modifier keys, which work alike to the action bar pages in said games. Usually these are the 1-9 keys, for Mudlet it'd be more convenient to use F1-12 however.

To implement this practicall, you have your F-keys set a variable to certain value. For example if you press F1, then a variable called modifier gets set to f1, to keep it simple. Now, on your numpad keys, you add an if statement, where if modifier is f1, you execute a certain skill. If f2, then another. You can also visualize this by having the UI update whenever an F-key is pressed. Say F1 corresponds to a page of walking keys, and F2 to a page of combat keys. If you press F1, the UI draws the walking keys, and when you press F2, it draws the combat keys. A framework like Vyzor can make this really simple to do, as you won't even have to redraw a whole element, only adjust that which changes.

Hope that makes sense! And do please go and suggest this in the request thread, would be neat to have, because in the end modifier keys > pages. And having both options = many, many more keybinds. I like keybinds, can you tell? :D

phasma: A quick Google shows me that QT can detect key states, but I don't know the slightest about it :(

kkerwin1
Posts: 22
Joined: Tue Apr 20, 2010 7:37 am

Re: Firing on Modifier Key Keypresses

Post by kkerwin1 »

Hrm. Another problem I was having:

SHIFT-KEYPAD-2 does not seem to work. It simply binds to "undefined key".

I'm familiar with programming in Qt, but have no idea how to do it inside of Mudlet, apart from grabbing the source code and modifying the core Mudlet code myself. Which does not sound fun.

User avatar
Vadi
Posts: 4901
Joined: Sat Mar 14, 2009 3:13 pm

Re: Firing on Modifier Key Keypresses

Post by Vadi »

Hm, I couldn't work out shift+keypad-2 either. Ctrl+keypad-2 works (just have numlock on), but shift+keypad-2 interprets the "2" as the down button, so it just changes the cursor to the code field. It would seem Qt is getting in the way here with it's keybinds first.

The code for this in Mudlet starts here when it sets the flag, and then on any event in the window it captures the keys.

kkerwin1
Posts: 22
Joined: Tue Apr 20, 2010 7:37 am

Re: Firing on Modifier Key Keypresses

Post by kkerwin1 »

@Vadi: Ya. I don't speak C++. My experience with Qt has been strictly limited to Python and PyQt.

I use KDE on all of my computers (but one), and I'm really hoping that we don't get screwed over with Nokia purportedly selling Qt...

User avatar
chris
Posts: 493
Joined: Fri Jun 17, 2011 5:39 am

Re: Firing on Modifier Key Keypresses

Post by chris »

Here's a list of keycodes:
http://doc.qt.nokia.com/4.7-snapshot/qt.html#Key-enum

The shift key is looked for. I'll see if it works right on windows, and check if a work-around is possible.

Post Reply