Hello, i’m trying to make a key manager, and have done up to one key per action management. What i want to add now is managing a combination of keys (alt + a, ctrl + b, so and so).
By itself it is pretty easy to do, really. The problem lies in the managers behavour when combinations overlap, ie : combination 1 : alt + a; combination 2 : alt + ctrl + a. I’d like to think i’ll just check what keys are pressed and choose the longer combination of those i detected. What i don’t know how to do is how to avoid random key pressing of the user : to get alt + ctrl + a you can hardly get all the keys at same time, so you’ll get either combination of those 3 keys in the first frame then over the next frames you’ll get the rest of the keys.
Since i’m pretty sure i didn’t explain the problem in a comprehensive way, here’s an exemple of user interaction and what the manager is supposed to do :
1 - We have the following combinations :
-
CTRL + A
-
ALT + A
-
CTRL + ALT + A
-
CTRL + SHIFT + A
-
ALT + SHIFT + A
-
CTRL + ALT + SHIFT + A
(i used these for the example and keeping it simple, not because i like the letter ‘A’ :))
So, when trying to get the combination CTRL+SHIFT+ALT+A (the order doesn’t matter), a user can press (then = next frame; and = same frame) :
#1 - CTRL, then ALT, then SHIFT, then A.
#2 - CTRL and ALT, then SHIFT, then A.
#3 - CTRL and ALT, then SHIFT and A.
#4 - CTRL and ALT and SHIFT, then A.
#5 - CTRL and ALT and SHIFT and A.
#6 - Any other combination between those.
If we take #2, you have CTRL and ALT, but if instead of ALT the user presses A…To my knowledge, the manager should activate the action 1), then, when the user adds another modifier, it passes onto that action (3) if it’s ALT, 4) if it’s SHIFT) and then getting 6) when all 3 modifiers are pressed. Am i on the right track here?
The problems i’m having is :
-
How should i check what combinations to ignore in case i don’t have the combination 6) and the keys pressed are CTRL + ALT + SHIFT + A.
-
In case i have also 7) CTRL + ALT + SHIFT + B, and the user is pressing (intentionaly or not) CTRL + ALT + SHIFT + A + B, what combinations do i validate?
Any ideas for these 2 problems?
Thank you in advance.