示例#1
0
 /// <summary>
 /// Returns whether the key with the particular keycode is pressed by checking the hardware directly.
 /// Currently functions identically to keyboard_check.
 /// </summary>
 /// <param name="key">The key to check the down state of.</param>
 /// <returns>Whether the key with the particular keycode is pressed by checking the hardware directly.</returns>
 public static bool keyboard_check_direct(vkeys key)
 {
     return keyboard_check(key);
 }
示例#2
0
 /// <summary>
 /// Returns whether the given key on the keyboard is currently held down.
 /// </summary>
 /// <param name="key">The key to check the down state of.</param>
 /// <returns>Whether the given key on the keyboard is currently held down.</returns>
 public static bool keyboard_check(vkeys key)
 {
     if (key == vkeys.vk_anykey)
     {
         return Keyboard.GetState().GetPressedKeys().Length > 0;
     }
     else if (key == vkeys.vk_nokey)
     {
         return Keyboard.GetState().GetPressedKeys().Length <= 0;
     }
     else if (key == vkeys.vk_shift)
     {
         return (Keyboard.GetState().IsKeyDown(Keys.LeftShift) || Keyboard.GetState().IsKeyDown(Keys.RightShift));
     }
     else if (key == vkeys.vk_control)
     {
         return (Keyboard.GetState().IsKeyDown(Keys.LeftControl) || Keyboard.GetState().IsKeyDown(Keys.RightControl));
     }
     else if (key == vkeys.vk_alt)
     {
         return (Keyboard.GetState().IsKeyDown(Keys.LeftAlt) || Keyboard.GetState().IsKeyDown(Keys.RightAlt));
     }
     return Keyboard.GetState().IsKeyDown((Keys)key);
 }