On unix systems, there are two "databases" that contain Information about terminal settings: terminfo and termcap; refer to man terminfo an man termcap for more details.
To start, check the Settings of your $TERM variable. Say its "xterm". On terminfo based systems, run infocmp to get the current Information about that terminal type, e.g. kf1=\EOP.
Check what key sequences your terminal really sends:
$ od -c [press enter]
0000000 033 [ 1 1 ~ \n
That means <ESC>[11~, which does not match <ESC>OP.
Hope that peace of Information will help you.