   showBoard(@board)
 
   $('body').keydown (e) =>
-    # e.preventDefault()
     key = e.which
     keys = [37..40]
 
     if key in keys
+      e.preventDefault()
       direction = switch key
         when 37 then 'left'
         when 38 then 'up'

    console.log row
  console.log "--- End ---"

getRow = (r, board) ->
  [board[r][0], board[r][1], board[r][2], board[r][3]]

mergeCells = (row, direction) ->
  if direction is 'right'
    for a in [3...0]
      for b in [a-1..0]
        console.log a, b

        if row[a] is 0 then break
        else if row[a] == row[b]


console.log mergeCells [4,4,4,4], 'right'

collapseCells = (row, direction) ->
  row = row.filter (ele) -> ele isnt 0
  if direction is 'right'
    while row.length < 4
      row.unshift 0
  else if direction is 'left'
    while row.length < 4
      row.push 0
  row

console.log collapseCells [0,4,4,0], 'right'



$ ->
  @board = buildBoard()
