zsh ctrl p same behavior as up arrow

By default Ctrl-P just jump back to the history while up arrow behave a little bit smarter.
For example if you have history like this
ssh a.com
ls
cd
ssh b.com
cat
grep
Normaly if you type $ ssh and Ctrl-P afterwares, it will give you grep not ssh b.com
to change this behavior, you can put this in your .zshrc
bindkey "^P" up-line-or-beginning-search
bindkey "^N" down-line-or-beginning-search