 
     return
 
-  handleMouseMove = (e) ->
-    pos = getMousePositionOnCanvas(e)
-    socket.emit 'mouse',
-      x: pos.x
-      y: pos.y
-      isDown: mouseDown
-    return
-
-  handleMouseDown = (e) ->
-    pos = getMousePositionOnCanvas(e)
-    socket.emit 'mouse',
-      x: pos.x
-      y: pos.y
-      isDown: 1
-    return
-
-  handleMouse2Down = (e) ->
-    e.preventDefault()
-    pos = getMousePositionOnCanvas(e)
-    socket.emit 'mouse',
-      x: pos.x
-      y: pos.y
-      isDown: 2
-    return
-
-  handleMouseUp = (e) ->
-    pos = getMousePositionOnCanvas(e)
-    socket.emit 'mouse',
-      x: pos.x
-      y: pos.y
-      isDown: 0
-    return
-
-  getMousePositionOnCanvas = (e) ->
-    mouseX = undefined
-    mouseY = undefined
-    if e.offsetX
-      mouseX = e.offsetX
-      mouseY = e.offsetY
-    else if e.layerX
-      mouseX = e.layerX
-      mouseY = e.layerY
-    {
-      x: mouseX
-      y: mouseY
-    }
-
-  handleKeydown = (event) ->
-    if event.keyCode == 8
-      event.preventDefault()
-    socket.emit 'keydown', key: codeConverter.convert(event.keyCode)
-    return
-
   isCapslock = (e) ->
     e = if e then e else window.event
     charCode = false

    mouseDown = 0
    return

  canvas = document.getElementById('screen')
  canvas.tabIndex = 1000
  ctx = canvas.getContext('2d')

  socket.on 'init', (data) ->
    canvas.width = data.width
    canvas.height = data.height
    canvas.addEventListener 'keydown', handleKeydown
    canvas.addEventListener 'mousedown', handleMouseDown
    canvas.addEventListener 'mouseup', handleMouseUp
    canvas.addEventListener 'mousemove', handleMouseMove
    canvas.addEventListener 'contextmenu', handleMouse2Down
    $scope.vmIsRunning = true
    return


    return

  $scope.$on '$destroy', ->
    socket.emit 'close'
    return
  return
