Syntax:
largevar = KeypadRawCommand Availability:
Available on all microcontrollers.
Explanation:
This function returns a 16-bit value, in which each bit corresponds
to a key on the keypad. If a key is pressed, its bit holds 1; if it is
released, its bit holds 0. Because every key gets its own bit, KeypadRaw can
detect multiple keys pressed at the same time — unlike KeypadData, which only ever reports one.
This table shows the key that each bit corresponds to:
| Bit | Key Position (row, col) | Common Key Symbol |
|---|---|---|
|
15 |
1,1 |
1 |
|
14 |
1,2 |
2 |
|
13 |
1,3 |
3 |
|
12 |
1,4 |
A |
|
11 |
2,1 |
4 |
|
10 |
2,2 |
5 |
|
9 |
2,3 |
6 |
|
8 |
2,4 |
B |
|
7 |
3,1 |
7 |
|
6 |
3,2 |
8 |
|
5 |
3,3 |
9 |
|
4 |
3,4 |
C |
|
3 |
4,1 |
* |
|
2 |
4,2 |
0 |
|
1 |
4,3 |
# |
|
0 |
4,4 |
D |
Example:
'Program to show the keypad status using LEDs
#chip 16F877A, 20
'Keypad connection settings
#define KeypadPort PORTB
'LEDs
#define LED1 PORTC
#define LED2 PORTD
Dir LED1 Out
Dir LED2 Out
'Declare a 16 bit variable for the key value
Dim KeyStatus As Word
'Main loop
Do
'Get key
KeyStatus = KeypadRaw ' <<< the KeypadRaw instruction
'Display
LED1 = KeyStatus_H 'High Byte
LED2 = KeyStatus 'Low Byte
LoopKey line: KeyStatus = KeypadRaw — reads all 16 key states at once into a single word, so any combination of simultaneously pressed keys can be recovered
by testing individual bits.
See Also:
- Keypad Overview
- KeypadData — the simpler single-key-value form

