如何使用箭头键移动鼠标光标

时间:2014-07-03 22:19:59

标签: objective-c cocoa mouseevent keyevent

如何按键移动我的鼠标光标? 那可能吗?我想出了如何注册按键并识别它是否为箭头,但我不确定是否可以使用该输入来移动鼠标

提前致谢!

1 个答案:

答案 0 :(得分:2)

CGWarpMouseCursorPosition方法应该做你想要的。 Apple Docs

CGPoint target = CGPointMake(10, 50);
// where 10 is x and 50 is y
CGWarpMouseCursorPosition(target);

当用户按下其中一个箭头键时,让它循环运行,直到不再按下该键。