Much easier way ...

Matrix Keypad routine (mister_e)
http://www.picbasic.co.uk/forum/showthread.php?t=3250
<br>