c# 捕捉键盘按键

//esc退出窗体
  protected override bool ProcessCmdKey(ref System.Windows.Forms.Message msg , System.Windows.Forms.Keys keyData) //激活回车键
  {
   int WM_KEYDOWN=256;       
   int WM_SYSKEYDOWN = 260;

if(msg.Msg == WM_KEYDOWN | msg.Msg == WM_SYSKEYDOWN)
   {
    switch(keyData)
    {
     case Keys.Escape:
      this.Close();//csc关闭窗体
      break;

  case Keys.F12:
      messagebox.show("F12");
      break;

}  
    
   }
   return false;
  }

上一篇:HDU 3572 Task Schedule(拆点+最大流dinic)


下一篇:js晋级篇——前端内存泄漏探讨