-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKeyboardInput.cs
More file actions
37 lines (32 loc) · 832 Bytes
/
KeyboardInput.cs
File metadata and controls
37 lines (32 loc) · 832 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;
using System.Text;
namespace Chip8
{
/// <summary>
/// Basic Keyboard input class that handles key presses.
/// </summary>
public static class KeyboardInput
{
private static KeyboardState State;
private static KeyboardState Previous;
public static void Initialize()
{
State = Keyboard.GetState();
}
public static void Update()
{
Previous = State;
State = Keyboard.GetState();
}
public static bool Check(Keys key)
{
return State.IsKeyDown(key);
}
public static bool CheckPressed(Keys key)
{
return Check(key) && !Previous.IsKeyDown(key);
}
}
}