Fixing Home and End keys in Vim

I'm using a SSH server app to access my android device's files. To make this environment more useful, I have improved many configurations, but Vim insists on printing H and F when pressing <Home> and <End> keys, respectively.

The solution I found to this was to remap the issued keys, adding the following to the vimrc file:

" For some reason home and end keys are not mapping properly.
" Home key
imap OH 0i
cmap OH 
nmap OH 0
" End key
nmap OF $
imap OF $a
cmap OF