void form_KeyDown(object sender, KeyEventArgs e) { Keys key = e.KeyData & ~Keys.Shift; if (KeysDown.Contains(key) == false) { KeysPressed.Add(key); KeysDown.Add(key); } }
public void KeyDown(object sender, KeyEventArgs e) { KeysPressed.Add(e.Code); if (Settings.Keybindings.ContainsKey(e.Code)) { Settings.Keybindings[e.Code](this); } Scene.ProcessKey(e); }
private static void AddOrSet(Keys key, bool value) { if (KeysPressed.ContainsKey(key)) { KeysPressed[key] = value; } else { KeysPressed.Add(key, value); } }
public void Device_KeyboardInput(object sender, KeyboardInputEventArgs e) { if (e.State == KeyState.Pressed) { if (KeysDown.Contains(e.Key) == false) { KeysPressed.Add(e.Key); KeysDown.Add(e.Key); } } else if (e.State == KeyState.Released) { KeysReleased.Add(e.Key); KeysDown.Remove(e.Key); } }
public void Action(string action) { var actionData = action.Split(' '); switch (actionData[0]) { case "key_down": { Enum.TryParse <ControlActions>(actionData[1], true, out var result); KeysPressed.Add(result); break; } case "key_up": { Enum.TryParse <ControlActions>(actionData[1], true, out var result); KeysPressed.Remove(result); break; } } }