# up
    elif y == mpos[1]:
        if mpos[0] - x > 0:
            key[1] = 1 # right
            key[0] = 0
        else:
            key[0] = 1 # left
            key[1] = 0
    e.preventDefault()
    e.stopPropagation()

doc.onkeydown = key_down
doc.onkeyup = key_up
doc.onmousedown = mouse_down
doc.ontouchstart = mouse_down
doc.onmousemove = mouse_move
doc.ontouchmove = mouse_move
doc.onmouseup = mouse_up
doc.ontouchup = mouse_up

def initUnderMap():
    underMap = doc["underMap"].getContext("2d")
    u