how to map keys for popup menu in vim

vim

Solution

function! OmniPopup(action)
    if pumvisible()
        if a:action == 'j'
            return "\<C-N>"
        elseif a:action == 'k'
            return "\<C-P>"
        endif
    endif
    return a:action
endfunction

inoremap <silent>j <C-R>=OmniPopup('j')<CR>
inoremap <silent>k <C-R>=OmniPopup('k')<CR>

Problem

After a completion try, omnicppcomplete will display all the possible items in the pop up menu . To select an certain item in the menu, one should use `<C-N>` and `<C-p>` to switch back and forth between different items. I feel that it is very inconvient . It should be very cool if `j` and `k` can be used to to take place of `<C-N>` and `<C-P>` . so how should I do ?

Original source