   constructor: (modeDiv, keybindingsDiv, view) ->
     @view = view
 
-    @bindings = defaultVimKeyBindings
-    do @buildKeyMap
+    @bindings = keyDefinitions
+    @keyMap = defaultVimKeyBindings
+
+    for k,v of @keyMap
+      if not @bindings[v].keys
+        @bindings[v].keys = []
+      @bindings[v].keys.push k
 
     if keybindingsDiv
       @keybindingsDiv = keybindingsDiv

        do @view.render
    DELETE:
      display: 'Delete (operator)'
      key: 'd'
    CHANGE:
      display: 'Change (operator)'
      key: 'c'
    DELETE_CHAR:
      display: 'Delete character'
      key: 'x'
      fn: () ->
        @view.delCharsAfterCursor @repeat, {yank: true}
        do @view.moveCursorBackIfNeeded
    DELETE_LAST_CHAR:
      display: 'Delete last character'
      key: 'X'
      fn: () ->
        num = Math.min @view.cursor.col, @repeat
        if num > 0
          @view.delCharsBeforeCursor num, {yank: true}
    CHANGE_CHAR:
      display: 'Change character'
      key: 's'
      insert: true
      fn: () ->
        @view.delCharsAfterCursor 1, {cursor: 'pastEnd'}, {yank: true}


    YANK:
      display: 'Yank (operator)'
    PASTE_AFTER:
      display: 'Paste after cursor'
      fn: () ->
        do @view.pasteAfter
    PASTE_BEFORE:
      display: 'Paste before cursor'
      fn: () ->
        do @view.pasteBefore

    INDENT_RIGHT:
      display: 'Indent right'
      fn: () ->
        @view.indentLine {}
    INDENT_LEFT:
      display: 'Indent left'
      fn: () ->
        @view.unindentLine {}
    INDENT_BLOCK_RIGHT:
      display: 'Indent block right'
      fn: () ->
        @view.indentBlock {recursive: true}
    INDENT_BLOCK_LEFT:
      display: 'Indent block left'
      fn: () ->
        @view.unindentBlock {recursive: true}
    TOGGLE_FOLD:
      display: 'Toggle whether a block is folded'
      fn: () ->
        do @view.toggleCurBlock
    SCROLL_DOWN:
      display: 'Scroll half window down'
      drop: true
      fn: () ->
        @view.scrollPages 0.5
    SCROLL_UP:
      display: 'Scroll half window down'
      drop: true
      fn: () ->
        @view.scrollPages -0.5

  MODES =
    NORMAL: 0
    INSERT: 1
    EX: 2

  defaultVimKeyBindings =
    '?': 'HELP'
    'i': 'INSERT'
    'a': 'INSERT_AFTER'
    'I': 'INSERT_HOME'
    'A': 'INSERT_END'
    'o': 'INSERT_LINE_BELOW'
    'O': 'INSERT_LINE_ABOVE'
    'r': 'REPLACE'
    ':': 'EX'
    'u': 'UNDO'
    'ctrl+r': 'REDO'
    '.': 'REPEAT'
    'h': 'LEFT'
    'left': 'LEFT'
    'l': 'RIGHT'
    'right': 'RIGHT'
    'k': 'UP'
    'up': 'UP'
    'j': 'DOWN'
    'down': 'DOWN'
    '0': 'HOME'
    '^': 'HOME'
    '$': 'END'
    'b': 'BEGINNING_WORD'
    'e': 'END_WORD'
    'w': 'NEXT_WORD'
    'B': 'BEGINNING_BLOCK'
    'E': 'END_BLOCK'
    'W': 'NEXT_BLOCK'
    'f': 'FIND_NEXT_CHAR'
    'F': 'FIND_PREV_CHAR'
    't': 'TO_NEXT_CHAR'
    'T': 'TO_PREV_CHAR'
    'g': 'GO'
    'G': 'GO_END'
    'd': 'DELETE'
    'c': 'CHANGE'
    'x': 'DELETE_CHAR'
    'X': 'DELETE_LAST_CHAR'
    's': 'CHANGE_CHAR'
    'y': 'YANK'
    'p': 'PASTE_AFTER'
    'P': 'PASTE_BEFORE'
    '>': 'INDENT_RIGHT'
    'tab': 'INDENT_RIGHT'
    '<': 'INDENT_LEFT'
    'shift+tab': 'INDENT_LEFT'
    ']': 'INDENT_BLOCK_RIGHT'
    '[': 'INDENT_BLOCK_LEFT'
    'z': 'TOGGLE_FOLD'
    'ctrl+d': 'SCROLL_DOWN'
    'ctrl+u': 'SCROLL_UP'

  SEQUENCE = {
    # wait for more keys
