Handling more than one keypress and detecting keyup event

霸气de小男生 提交于 2019-12-08 19:07:28

Keys is a flagged enumeration. Which means you can use bitwise comparisons to see if more than one key is pressed simultaneously.

case Keys.Up & Keys.Right:
    ...
    break;

You can also check for individual keys using checks like the following:

if ((keyData & Keys.Up) == Keys.Up) 
    GoForward();
if ((keyData & Keys.Right) == Keys.Right) 
    GoRight();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!