Skip to main content
8 of 9
added 3 characters in body
Tymric
  • 671
  • 4
  • 14

Python 418 351 314 300 275 Bytes

Edit: Saved 67 104 118 143 Bytes thanks to the advice in the comments

from win32api import*
from msvcrt import*
s=137
G=GetSystemMetrics
S=SetCursorPos
x=G(0)//2
y=G(1)//2
c=3**.5
Y=y-2*s/c
S((x,y))
while(kbhit()and ord(getch())==27)<1:a,b=GetCursorPos();S((min(max(a,x-s),x+s),min(max(b,int(c*a+Y-c*x),int(-c*a+Y+c*x)),int(y+s/c))))

Written in Python 3.4.1 on Windows, pywin needs to be installed.

My first code golf submission. Please feel free to suggest improvements

Tymric
  • 671
  • 4
  • 14