/
FlxKeyboard.cs
71 lines (65 loc) · 1.86 KB
/
FlxKeyboard.cs
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
namespace fliXNA_xbox
{
public class FlxKeyboard
{
private KeyboardState old;
private KeyboardState current;
static public Buttons buttons;
public FlxKeyboard()
{
}
public void update()
{
old = current;
current = Keyboard.GetState();
}
/// <summary>
/// Returns true if the specified Key was just pressed
/// </summary>
/// <param name="Key"></param>
/// <returns></returns>
public bool justPressed(Keys Key)
{
if ((current.IsKeyDown(Key) && old.IsKeyUp(Key)))
return true;
else
return false;
}
/// <summary>
/// Returns true if the specified Key was just released
/// </summary>
/// <param name="Key"></param>
/// <returns></returns>
public bool justReleased(Keys Key)
{
if ((old.IsKeyDown(Key) && current.IsKeyUp(Key)))
return true;
else
return false;
}
/// <summary>
/// Returns true if the specified Key is held down
/// </summary>
/// <param name="Key"></param>
/// <returns></returns>
public bool pressed(Keys Key)
{
if (current.IsKeyDown(Key))
return true;
else
return false;
}
}
}