Why does insert-mode map "<F4>" unpredictably inserts itself or executes intended key strokes?

view story

http://unix.stackexchange.com – In Vim 7.3.1-762, mintty 1.1.2 (xterm), cygwin, Windows XP, the insert-mode map <F4> executes the intended key strokes at one time but inserts itself at another time. This undeterministic behavior especially occurs if I hold the <F4> key depressed. How do I make the behavior predictable accross multiple Vim-, terminal- and operating system versions? This is the code I defined in my ~/.vimrc file, that seems relevant to me: set compatible set timeout set ttimeout set timeoutlen=1000 set ttimeoutlen=100 imap <F4> <C-\><C-O>:set relativenumber! relativenumber?< (HowTos)