This depends alot on how your keypad is wired, and how many resistors there are in the circuit, but there's a possibility you have a short circuit waiting to happen.
By setting PORTB to either High or LOW states, if you accidently press 2 buttons (on different colums), it put's a dead short across the outputs of the PIC.
Typically, it causes the PIC to reset before it can do any real damage. But over time it will take it's toll on the equipment. Especially the keypad.
It's better to control the TRIS register, so that only 1 column has an active output at any given time.
I know you're trying to do it yourself, but you might want to take a look at ...
keyx.bas - PICBASIC PRO program to display key number on LCD http://www.melabs.com/resources/samples/x1/pbp/keyx.bas
HTH,
Bookmarks