sneak/Shared/KeyboardInput.cs
Colin McMillen 096f577e61 change namespace to SemiColinGames
GitOrigin-RevId: 3c4e116e770edfcca7f661b3f0d74bb312aa6a04
2020-02-13 14:48:35 -05:00

24 lines
602 B
C#

using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
namespace SemiColinGames {
public class KeyboardInput {
private KeyboardState oldState = Keyboard.GetState();
private List<Keys> newKeysDown = new List<Keys>();
public void Update() {
KeyboardState newState = Keyboard.GetState();
newKeysDown.Clear();
foreach (Keys k in newState.GetPressedKeys()) {
if (!oldState.IsKeyDown(k)) {
newKeysDown.Add(k);
}
}
oldState = newState;
}
public List<Keys> NewKeysDown() {
return newKeysDown;
}
}
}