Add Custom Key for SOL on webui

To support VT100+ extensions for SOL on webui, add custom key
into xtermjs to handle key Backspace, DEL, HOME, END, INSERT,
PAGE UP, PAGE DOWN, F1 - F12.

Tested By:
After added item "customKeyEnable": true, "keyType" : "VT100+" into
iconfig.json.
Under EFI SHELL: Backspace, DEL, HOME, END, INSERT, PAGE UP, PAGE DOWN,
F1 - F12 keys can work as local keyboard in Web SOL.
Under linux with $TERM=vt100+: Backspace, DEL, HOME, END, INSERT,
PAGE UP, PAGE DOWN, F1 - F12 keys can work as local keyboard in Web SOL.
If not add "customKeyEnable" or "keyType", into config.json, Backspace,
DEL, HOME, END, INSERT, PAGE UP, PAGE DOWN, F1 - F12 keys can work
correctly in linux OS with $TERM=vt220 in SOL.
Other keys such as a-z can always work in SOL no matter "customKeyEnable"
or "keyType" is inserted into config.json.

Change-Id: Ifb196ec37080781033c0d6a3b0688baa7d0080b5
Signed-off-by: Cheng C Yang <cheng.c.yang@linux.intel.com>
diff --git a/app/common/directives/vt100plus.js b/app/common/directives/vt100plus.js
new file mode 100644
index 0000000..5433b2a
--- /dev/null
+++ b/app/common/directives/vt100plus.js
@@ -0,0 +1,126 @@
+'use strict';
+
+var EscapeSequences = require('xterm/lib/common/data/EscapeSequences');
+
+var BACKSPACE = 8;
+var PAGE_UP = 33;
+var PAGE_DOWN = 34;
+var END = 35;
+var HOME = 36;
+var INSERT = 45;
+var DEL = 46;
+var F1 = 112;
+var F2 = 113;
+var F3 = 114;
+var F4 = 115;
+var F5 = 116;
+var F6 = 117;
+var F7 = 118;
+var F8 = 119;
+var F9 = 120;
+var F10 = 121;
+var F11 = 122;
+var F12 = 123;
+
+/*
+VT100+ Character and Key Extensions
+
+Character or key  | Character sequence
+---------------------------------------
+HOME key          | <ESC>h
+END key           | <ESC>k
+INSERT key        | <ESC>+
+DELETE key        | <ESC>-
+PAGE UP key       | <ESC>?
+PAGE DOWN key     | <ESC>/
+F1 key            | <ESC>1
+F2 key            | <ESC>2
+F3 key            | <ESC>3
+F4 key            | <ESC>4
+F5 key            | <ESC>5
+F6 key            | <ESC>6
+F7 key            | <ESC>7
+F8 key            | <ESC>8
+F9 key            | <ESC>9
+F10 key           | <ESC>0
+F11 key           | <ESC>!
+F12 key           | <ESC>@
+
+*/
+
+function customVT100PlusKey(ev, term) {
+  var modifiers = (ev.shiftKey ? 1 : 0) | (ev.altKey ? 2 : 0) |
+      (ev.ctrlKey ? 4 : 0) | (ev.metaKey ? 8 : 0);
+  if (((modifiers) && (ev.keyCode != BACKSPACE)) || (ev.type != 'keydown')) {
+    return true;
+  }
+  switch (ev.keyCode) {
+    case BACKSPACE:
+      if (ev.altKey) {
+        return true;
+      } else if (!ev.shiftKey) {
+        term.handler(EscapeSequences.C0.BS);  // Backspace
+      } else {
+        term.handler(EscapeSequences.C0.DEL);  // Delete
+      }
+      break;
+    case PAGE_UP:
+      term.handler(EscapeSequences.C0.ESC + '?');
+      break;
+    case PAGE_DOWN:
+      term.handler(EscapeSequences.C0.ESC + '/');
+      break;
+    case END:
+      term.handler(EscapeSequences.C0.ESC + 'k');
+      break;
+    case HOME:
+      term.handler(EscapeSequences.C0.ESC + 'h');
+      break;
+    case INSERT:
+      term.handler(EscapeSequences.C0.ESC + '+');
+      break;
+    case DEL:
+      term.handler(EscapeSequences.C0.ESC + '-');
+      break;
+    case F1:
+      term.handler(EscapeSequences.C0.ESC + '1');
+      break;
+    case F2:
+      term.handler(EscapeSequences.C0.ESC + '2');
+      break;
+    case F3:
+      term.handler(EscapeSequences.C0.ESC + '3');
+      break;
+    case F4:
+      term.handler(EscapeSequences.C0.ESC + '4');
+      break;
+    case F5:
+      term.handler(EscapeSequences.C0.ESC + '5');
+      break;
+    case F6:
+      term.handler(EscapeSequences.C0.ESC + '6');
+      break;
+    case F7:
+      term.handler(EscapeSequences.C0.ESC + '7');
+      break;
+    case F8:
+      term.handler(EscapeSequences.C0.ESC + '8');
+      break;
+    case F9:
+      term.handler(EscapeSequences.C0.ESC + '9');
+      break;
+    case F10:
+      term.handler(EscapeSequences.C0.ESC + '0');
+      break;
+    case F11:
+      term.handler(EscapeSequences.C0.ESC + '!');
+      break;
+    case F12:
+      term.handler(EscapeSequences.C0.ESC + '@');
+      break;
+    default:
+      return true;
+  }
+  return false;
+}
+exports.customVT100PlusKey = customVT100PlusKey;