'use strict';

var OPT = require('./optkeys');
var fromUnicode = require('./').fromUnicode;

var _shortcuts = {
  // option-keys to press for shortcuts
  OPT.A: '☺', OPT.B: '☻',
  OPT.C: '♥', OPT.D: '♦',
  /*OPT.E: '♣'*/, OPT.F: '♠',
  OPT.G: '•', OPT.H: '◘',
  /*OPT.I: '○'*/, OPT.J: '◙',
  OPT.K: '♂', OPT.L: '♀',
  OPT.M: '☼', /*OPT.N: '▒',*/
  OPT.O: '←', OPT.P: '→',
  OPT.Q: '↑', OPT.R: '↓',
  OPT.S: '◄', OPT.T: '►',
  /*OPT.U: '▲',*/ OPT.V: '▼',
};

function fromEvent(ev) {
  // TODO: use only keyCode, keydown event instead of keypress?
  if (ev.keyCode === 13) { // ASCII carriage return, enter/newline
    return 12; // trit-text newline
  }

  var c = ev.charCode;

  if (_shortcuts[c] !== undefined) {
    c = _shortcuts[c];
  }

  var tt = fromUnicode(c);
  if (tt == null) return null;

  if (ev.metaKey || ev.ctrlKey) tt = -tt; // TODO: other key? option?

  return tt;
}

module.exports = fromEvent;

@@ -90,29 +90,8 @@
 e;%0A%0A
-var _shortcuts = %7B%0A  
 // o
@@ -128,311 +128,432 @@
 uts%0A
-  
+var _sc = %7B%7D;%0A_sc%5B
 OPT.A
-:
+%5D =
  '%E2%98%BA'
-, 
+; _sc%5B
 OPT.B
-:
+%5D =
  '%E2%98%BB'
-,%0A  
+;%0A_sc%5B
 OPT.C
-:
+%5D =
  '%E2%99%A5'
-, 
+; _sc%5B
 OPT.D
-:
+%5D =
  '%E2%99%A6'
-,%0A  /*
+;%0A/*_sc%5B
 OPT.E
-:
+%5D =
  '%E2%99%A3'*/
-, 
+; _sc%5B
 OPT.F
-:
+%5D =
  '%E2%99%A0'
-,%0A  
+;%0A_sc%5B
 OPT.G
-:
+%5D =
  '%E2%80%A2'
-, 
+; _sc%5B
 OPT.H
-:
+%5D =
  '%E2%97%98'
-,%0A  /*
+;%0A/*_sc%5B
 OPT.I
-:
+%5D =
  '%E2%97%8B'*/
-, 
+; _sc%5B
 OPT.J
-:
+%5D =
  '%E2%97%99'
-,%0A  
+;%0A_sc%5B
 OPT.K
-:
+%5D =
  '%E2%99%82'
-, 
+; _sc%5B
 OPT.L
-:
+%5D =
  '%E2%99%80'
-,%0A  
+;%0A_sc%5B
 OPT.M
-:
+%5D =
  '%E2%98%BC'
-,
+;
  /*
+_sc%5B
 OPT.N
-:
+%5D =
  '%E2%96%92'
-,*/%0A  
+;*/%0A_sc%5B
 OPT.O
-:
+%5D =
  '%E2%86%90'
-, 
+; _sc%5B
 OPT.P
-:
+%5D =
  '%E2%86%92'
-,%0A  
+;%0A_sc%5B
 OPT.Q
-:
+%5D =
  '%E2%86%91'
-, 
+; _sc%5B
 OPT.R
-:
+%5D =
  '%E2%86%93'
-,%0A  
+;%0A_sc%5B
 OPT.S
-:
+%5D =
  '%E2%97%84'
-, 
+; _sc%5B
 OPT.T
-:
+%5D =
  '%E2%96%BA'
-,%0A  /*
+;%0A/*_sc%5B
 OPT.U
-:
+%5D =
  '%E2%96%B2'
-,
+;
 */ 
+_sc%5B
 OPT.V
-:
+%5D =
  '%E2%96%BC'
-,%0A%7D
 ;%0A%0Af
@@ -780,24 +780,17 @@
   if (_s
-hortcuts
+c
 %5Bc%5D !== 
@@ -812,24 +812,17 @@
   c = _s
-hortcuts
+c
 %5Bc%5D;%0A  %7D

Fix object syntax in shortcuts