shell.c: skip direction key, page up/down, and esc key and code refinement

The code are reused from embedded 2013