Hi Evgeni
The key pad support is an example of how a matrix keyboard can be controlled. If you configure
#define KEY_ROWS 1
#define KEY_COLUMNS 4
it will more or less do a single 4 inputs, although a rather over-complicated method.
By simply reading the port and checking the 4 inputs is of course a much simpler method, but I don't think that this is the main topic here.
As you already know, the example generates events (on press and on release of keys) which are sent to the application task where they can write a message to the UART (or of course be used to do other jobs).
Since key presses and also key releases are events, it is in fact very easy for the application to also decide when certain combinations of keys are pressed, it must simply remember and react accordingly.
Here is an example (assuming the events KEY_EVENT_COL_1_ROW_1_PRESSED, KEY_EVENT_COL_1_ROW_1_RELEASED,
KEY_EVENT_COL_2_ROW_1_PRESSED, KEY_EVENT_COL_2_ROW_1_RELEASED, etc.)
static int iKeysPressed[4] = {0};
handle events
switch (event) {
case KEY_EVENT_COL_1_ROW_1_PRESSED:
iKeysPressed[0] = 1;
break;
case KEY_EVENT_COL_2_ROW_1_PRESSED:
iKeysPressed[1] = 1;
break;
case KEY_EVENT_COL_3_ROW_1_PRESSED:
iKeysPressed[2] = 1;
break;
case KEY_EVENT_COL_4_ROW_1_PRESSED:
iKeysPressed[3] = 1;
if (iKeysPressed[1] != 0) { // special case when 4 is pressed while 2 is hold
// do something here
}
break;
case KEY_EVENT_COL_1_ROW_1_RELEASED:
iKeysPressed[0] = 0;
break;
case KEY_EVENT_COL_2_ROW_1_RELEASED:
iKeysPressed[1] = 0;
break;
case KEY_EVENT_COL_3_ROW_1_RELEASED:
iKeysPressed[2] = 0;
break;
case KEY_EVENT_COL_4_ROW_1_RELEASED:
iKeysPressed[3] = 0;
break;
}
Regards
Mark