Detecting multiple key presses on MX2

LK/ELK/VK/PK/OK/MX/GLK/EGLK/GVK/GLT Series

Moderators: Henry, Mods

roofrack
LCD?
Posts: 7
Joined: Wed Sep 17, 2003 5:20 pm
Location: Leigh, Lancashire, UK

Detecting multiple key presses on MX2

Post by roofrack »

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 ?

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

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!)

dtorner
LCD Geek
Posts: 36
Joined: Fri Aug 23, 2002 6:00 pm
Location: Zaragoza, Spain

Post by dtorner »

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.

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

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!)

dtorner
LCD Geek
Posts: 36
Joined: Fri Aug 23, 2002 6:00 pm
Location: Zaragoza, Spain

Post by dtorner »

mat-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.
With all my respects Mat :wink: : Did you read MX2 manual cap 3.4.1 ??
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... <:)

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

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!)

dtorner
LCD Geek
Posts: 36
Joined: Fri Aug 23, 2002 6:00 pm
Location: Zaragoza, Spain

Post by dtorner »

Yep It's a limitation/feature , extracted from Manual :

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).
So you are right too Mat, It can't be done. But anyways this works with LCDC in the way I explain before...

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

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!)

roofrack
LCD?
Posts: 7
Joined: Wed Sep 17, 2003 5:20 pm
Location: Leigh, Lancashire, UK

Food for thought

Post by roofrack »

Glad to see my question generated some discussion - even it didn't particularly give me the answer I wanted to hear ! :cry:

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 ?

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

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!)

dtorner
LCD Geek
Posts: 36
Joined: Fri Aug 23, 2002 6:00 pm
Location: Zaragoza, Spain

Post by dtorner »

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... :D :D :D

Mat-Moo
LCD Guru
Posts: 502
Joined: Wed Jan 16, 2002 4:00 pm
Contact:

Post by Mat-Moo »

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!)

dtorner
LCD Geek
Posts: 36
Joined: Fri Aug 23, 2002 6:00 pm
Location: Zaragoza, Spain

Post by dtorner »

mat-d-rat wrote:Tis odd, don't do that on my mx2 unit!
Grrhhhh, Mine is one of the first USB units, Rev1.0. BTW I'm happy because I CAN do It :lol:

Paradigm
Matrix Orbital
Matrix Orbital
Posts: 255
Joined: Thu Sep 13, 2001 6:00 pm
Location: Calgary, Alberta, Canada

Post by Paradigm »

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.
James McTavish, P.Eng
Director of Engineering
Matrix Orbital

dtorner
LCD Geek
Posts: 36
Joined: Fri Aug 23, 2002 6:00 pm
Location: Zaragoza, Spain

Post by dtorner »

I see, but my unit returns different codes when I press some keys simultaneously. Maybe is a hardware "bug"...

Post Reply