ssh/terminal: support ^N and ^P

This makes it possible to navigate the history without leaving
the home row on the keyboard.

Change-Id: Id24c43f8eb6090520ab37bf8126264901b70c489
Reviewed-on: https://go-review.googlesource.com/c/33618
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
diff --git a/ssh/terminal/terminal.go b/ssh/terminal/terminal.go
index 9a88759..9d666ff 100644
--- a/ssh/terminal/terminal.go
+++ b/ssh/terminal/terminal.go
@@ -159,6 +159,10 @@
 			return keyClearScreen, b[1:]
 		case 23: // ^W
 			return keyDeleteWord, b[1:]
+		case 14: // ^N
+			return keyDown, b[1:]
+		case 16: // ^P
+			return keyUp, b[1:]
 		}
 	}
 
diff --git a/ssh/terminal/terminal_test.go b/ssh/terminal/terminal_test.go
index 5e5d33b..3ae9116 100644
--- a/ssh/terminal/terminal_test.go
+++ b/ssh/terminal/terminal_test.go
@@ -92,6 +92,12 @@
 		in: "\x1b[B\r", // down
 	},
 	{
+		in: "\016\r", // ^P
+	},
+	{
+		in: "\014\r", // ^N
+	},
+	{
 		in:   "line\x1b[A\x1b[B\r", // up then down
 		line: "line",
 	},