matrix- to 4-bit keypad encoder

A keypad-matrix is very nice, but.. they have disadvantages if used with microcontrollers.
For a 3 X 4 keypad you need 7 I/O-pins.
Such a keypad wants pullup resistors.
So, you have to realise that in hardware, or you are forced to a port that has software pullups.If you use portB, (with PIC-controllers) then you've lost your external interrupt lines.
The scanning of a matrix is, for a controller, a time wasting task.
Did i say "you need 7 I/O pins"? Well, make it 8 pins. The inkey command is doing "things" with portB.7 in a way that i can't use that pin as an input.
Inkey has taken the last from portB too !
users.picbasic.org