Hi Srigopal007,

Assuming you have Pull-Up resistors on PORTD.3,4,5,6 and 7

Try this on for size.

Code:
col var word ' Keypad column
row var word ' Keypad row
key var word ' Key value
i var word

getkeyu:
' Wait for all keys up
    PORTD = 0                   ' All output pins low
    TRISD = $F8                 ' Bottom 3 pins out, top 5 pins in
    If ((PORTD >> 3) != $1f) Then getkeyu   ' If any keys down, loop

Pause 50 ' Debounce

getkeyp:
    ' Wait for keypress 
    For col = 0 to 2               ' 3 columns in keypad
        PORTD = 0                  ' All output pins low
        TRISD = (dcd col) ^ $ff    ' Set one column pin to output
        row = PORTD >> 3           ' Read row
        If row != $1f Then         ' If any keydown, exit
            key = (col * 5) + (ncd (row ^ $1f))
        endif
    Next col

Goto getkeyp                     ' No keys down, go look again
The key numbering is different than you expected too.
<font size=3><pre>Col : 0 1 2<br>==============<br> 1 6 11 (ROW0)<br> 2 7 12 (ROW1)<br> 3 8 13 (ROW2)<br> 4 9 14 (ROW3)<br> 5 10 15 (ROW4)</pre></font>HTH,
&nbsp;&nbsp;&nbsp;Darrel