• 快捷键Alt、Shift、Ctrl 点击事件


    //场景初始化函数
    public StartScene()
    {
      this.KeyDown += ModelViewerControl_KeyDown;
      his.KeyUp += ModelViewerControl_KeyUp;
    }

    bool alt_key_flag = false;

    bool shift_key_flag = false;

    bool ctrl_key_flag = false;


    //键盘按键按下事件
    void ModelViewerControl_KeyDown(object sender, KeyEventArgs e)
    {
      //1.常规点击 KeyDown 方法
      if (System.Windows.Forms.Keys.ShiftKey == e.KeyCode)
      {
        shift_key_flag = true;
      }
      if (System.Windows.Forms.Keys.ControlKey == e.KeyCode)
      {
        ctrl_key_flag = true;
      }
      //2.alt.shift.ctrl 点击 KeyDown 方法
      if (e.Alt)
      {
        alt_key_flag = true;
      }
      if (e.Shift)
         {
        shift_key_flag = true;
      }
      if (e.Control)
      {
        ctrl_key_flag = true;
      }
      //3.alt.shift.ctrl 点击 KeyDown 方法
      if (System.Windows.Forms.Keys.Alt==e.Modifiers)
      {
        alt_key_flag = true;
      }
      if (System.Windows.Forms.Keys.Shift == e.Modifiers)
      {
        shift_key_flag = true;
      }
      if (System.Windows.Forms.Keys.Control == e.Modifiers)
      {
        ctrl_key_flag = true;
      }
    }
    //键盘按键抬起事件
    void ModelViewerControl_KeyUp(object sender, KeyEventArgs e)
    {
      //1.常规点击 KeyUp 方法
      if (System.Windows.Forms.Keys.ShiftKey == e.KeyCode)
      {
        shift_key_flag = false;
      }
      if (System.Windows.Forms.Keys.ControlKey == e.KeyCode)
      {
        ctrl_key_flag = false;
      }
      //2.alt.shift.ctrl 点击 KeyUp 方法
      if (!e.Alt)
      {
        alt_key_flag = false;
      }
      if (!e.Shift)
      {
        shift_key_flag = false;
      }
      if (!e.Control)
      {
        ctrl_key_flag = false;
      }
      //3.alt.shift.ctrl 点击 KeyUp 方法
      if (System.Windows.Forms.Keys.Alt!=e.Modifiers)
      {
        alt_key_flag = false;
      }
      if (System.Windows.Forms.Keys.Shift != e.Modifiers)
      {
        shift_key_flag = false;
      }
      if (System.Windows.Forms.Keys.Control != e.Modifiers)
      {
        ctrl_key_flag = false;
      }
    }

    支持个人观看使用,如商用或转载,请告知! -----萧朗(QQ:453929789 Email:xiaolang_xl@sina.com)
  • 相关阅读:
    Codeforces Gym 101142C:CodeCoder vs TopForces(搜索)
    L2-011. 玩转二叉树
    zoj 2976 Light Bulbs(暴力枚举)
    ZOJ 2975 Kinds of Fuwas(暴力+排列组合)
    ZOJ-2972-Hurdles of 110m(线性dp)
    ZOJ 2971 Give Me the Number (模拟,字符数组的清空+map)
    zoj 2966 Build The Electric System(最小生成树)
    ZOJ 2965 Accurately Say "CocaCola"!(预处理)
    HDU 3452 Bonsai(树形dp)
    zoj 3212 K-Nice(构造)
  • 原文地址:https://www.cnblogs.com/XiaoLang0/p/11010263.html
Copyright © 2020-2023  润新知