C# 中获取 F1等功能键,Up方向键

来源:互联网 发布:淘宝的宜家代购 编辑:程序博客网 时间:2024/06/14 20:26

在KeyPress中无法捕捉到事件

private void MainForm_KeyPress(object sender, KeyPressEventArgs e)
        {
            if(e.KeyChar.ToString().ToUpper() == Keys.Up.ToString())
            {
            }

        }


必须在KeyDown中处理
 private void MainForm_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Up)
            {
                            }

            if (e.KeyCode == Keys.Down)
            {
                               
            } 
        }