Hello!
Beside the comments that indeed would be useful, you write twice the
same code at the end (P0 = 0x0b, etc…). At first it started with P0 = 0x0e,
then 0x0d, then 0x0b, so I guess the last one should be 0x07 instead of 0x0b.
And the last case: key = ' seems suspicious to me. Probably you wanted to
write key = '#';
Last thing. Somebody already told you, but let's put it in other words: you are
mixing integers and printable characters. Write all the keys between quotes,
or all the keys as integers, but don't mix.
Dora.