Detecting multiple key presses on MX2
Detecting multiple key presses on MX2
I will be programming an MX2 (USB) for a project for my company, having just purchased 2 x MX2 on a trial basis. The language will be VB6.
The MX2 features seven keys. I was wondering if there was a way of combining these together to make more key combinations that can be distinguished from one another. It seems to me this might be done in one of a number of ways:
1 - Detect two sequential key presses within a fixed period of time, e.g. I might want the ENTER, F1 and F2 keys to mean something if pressed individually but, when combined, ENTER + F1 might mean "go into menu mode", ENTER + F2 means "come out of menu mode", or,
2 - As above, but somehow detect two keys being pressed simultaneously (e.g. use one of the seven keys as a meta key, like a SHIFT function)
Sorry if this sounds a bit naive, but is any of this feasible, and what sort of programming technique is required ? Anyone done it before ? Any examples ?
The MX2 features seven keys. I was wondering if there was a way of combining these together to make more key combinations that can be distinguished from one another. It seems to me this might be done in one of a number of ways:
1 - Detect two sequential key presses within a fixed period of time, e.g. I might want the ENTER, F1 and F2 keys to mean something if pressed individually but, when combined, ENTER + F1 might mean "go into menu mode", ENTER + F2 means "come out of menu mode", or,
2 - As above, but somehow detect two keys being pressed simultaneously (e.g. use one of the seven keys as a meta key, like a SHIFT function)
Sorry if this sounds a bit naive, but is any of this feasible, and what sort of programming technique is required ? Anyone done it before ? Any examples ?
No this can't be done. But LCDC does do something similar as you can denote a key as a type of shift-lock to turn shift on/off. Hope that helps.
## # Mat # ##
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
So, I think it can be done, It you activate KeyPad auto repeat mode (Read manual cap:3.4.1), 2 values are returned, one for KeyDown and one for KeyUp, for ex.:
Enter Key down : returns J
Enter Key Up : returns j
Up Key down : returns K
Up key Up : returns k
So if returned values are "J" "K" "k" then user press and release 'Up key' while pressing 'Enter key', if user releases 'Enter Key' before press 'Up Key' you get "J" "j" "K" "k"
I think this is possible, IMHO.
Enter Key down : returns J
Enter Key Up : returns j
Up Key down : returns K
Up key Up : returns k
So if returned values are "J" "K" "k" then user press and release 'Up key' while pressing 'Enter key', if user releases 'Enter Key' before press 'Up Key' you get "J" "j" "K" "k"
I think this is possible, IMHO.
I don't think that is correct dtorner, key pad autorepeat just repeats the same key e.g JJJJJJJJJJJJJJJJ it does not report keydown and keyup as it is only simple contract stuff it does report.
## # Mat # ##
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
With all my respects Matmat-d-rat wrote:I don't think that is correct dtorner, key pad autorepeat just repeats the same key e.g JJJJJJJJJJJJJJJJ it does not report keydown and keyup as it is only simple contract stuff it does report.

Maybe I'm wrong with this, but I use this feature with LCDC to show a screen only while I'm pressing Enter Key, If I release the key, LCDC goes to other screen... so this should work...

Appologies mate you are correct
However in testing it don't work... Go into the LCDC test area, send [##254,126,1] to turn this mode on and 2 key strokes are sent as expected when you press a key:e.g. jJ - however if you press and hold j then press any other key it only responds with jJ jJ still and not the other key value. Be this a bug or a limitation, I'm not sure.

## # Mat # ##
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
Yep It's a limitation/feature , extracted from Manual :
So you are right too Mat, It can't be done. But anyways this works with LCDC in the way I explain before...
Code: Select all
In this mode, when a key is held down, the key code is transmitted immediately and no other codes will
be sent until the key is released. On the release of the key, the key release code transmitted will be a
value equal to the key down code plus 20 hex. For example, the key code associated with key 'P' (0x50)
is pressed, the release code is 'p' (0x70).
BTW Dtoner, neat idea for momentarty screen using that in the two keypress mode! 

## # Mat # ##
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
Food for thought
Glad to see my question generated some discussion - even it didn't particularly give me the answer I wanted to hear !
But then, thinking about it, perhaps in VB I could use a technique whereby I use the MSComm control to wait for characters off the USB serial port. As soon as I receive an OnComm event, I read the character, then start a VB Timer of, say, 750 millis. If I get another OnComm event before the timer runs out, I know I've got two key presses within that time period, cancel the timer, and treat it as a special key combination. If no other key press happens, I just process the first on its own.
Sound practical ?

But then, thinking about it, perhaps in VB I could use a technique whereby I use the MSComm control to wait for characters off the USB serial port. As soon as I receive an OnComm event, I read the character, then start a VB Timer of, say, 750 millis. If I get another OnComm event before the timer runs out, I know I've got two key presses within that time period, cancel the timer, and treat it as a special key combination. If no other key press happens, I just process the first on its own.
Sound practical ?
I don't know about practical, but you could possibly hack it to do that. Although as stated you would not know what key it is just that another key had been pressed, or that the same key was possibly double pressed.
## # Mat # ##
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
I'm playing with my KeyPad and I note a strange/usefull thing, I test after send [##254,126,0] (auto repeat keys) to display.And display returns :
Enter : J
F1 : Q
F2 : P
Up : K
Down: L
Left : R
Right : F
Enter + F1 : c
Enter + F2 : b
Enter + Left : d
Enter + Right : d (same Enter + Left return)
So,I think this CAN be done in an easy way, try yourself...

Enter : J
F1 : Q
F2 : P
Up : K
Down: L
Left : R
Right : F
Enter + F1 : c
Enter + F2 : b
Enter + Left : d
Enter + Right : d (same Enter + Left return)
So,I think this CAN be done in an easy way, try yourself...



Tis odd, don't do that on my mx2 unit!
## # Mat # ##
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
LCDC - Drive it to the edge baby!
http://www.lcdc.cc
Matthew@DPS.uk.com
DPS Ltd. (Not MO!)
-
- Matrix Orbital
- Posts: 255
- Joined: Thu Sep 13, 2001 6:00 pm
- Location: Calgary, Alberta, Canada
None of our units will detect multiple simultaneous keypresses.
Even in the key down/key up mode mentioned (where it sends the upper case to denote key down and the lower case to denote key up), a key up MUST be sent before another key down can occur. It is a limitation of the matrix keypad system and can't be fixed.
As mentioned, you could do sequential key combinations. For example: In a menu when you press down it will select the next line, but if you press F1 then down, it will go a page down in the menu. Use key combinations that are pressed one after the other rather at the same time.

As mentioned, you could do sequential key combinations. For example: In a menu when you press down it will select the next line, but if you press F1 then down, it will go a page down in the menu. Use key combinations that are pressed one after the other rather at the same time.
James McTavish, P.Eng
Director of Engineering
Matrix Orbital
Director of Engineering
Matrix Orbital