-
-
Notifications
You must be signed in to change notification settings - Fork 909
/
KeyboardDeviceExtensions.cs
41 lines (38 loc) · 1.79 KB
/
KeyboardDeviceExtensions.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
// Copyright (c) Stride contributors (https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
namespace Stride.Input
{
public static class KeyboardDeviceExtensions
{
/// <summary>
/// Determines whether the specified key is pressed since the previous update.
/// </summary>
/// <param name="keyboardDevice">The keyboard</param>
/// <param name="key">The key</param>
/// <returns><c>true</c> if the specified key is pressed; otherwise, <c>false</c>.</returns>
public static bool IsKeyPressed(this IKeyboardDevice keyboardDevice, Keys key)
{
return keyboardDevice.PressedKeys.Contains(key);
}
/// <summary>
/// Determines whether the specified key is released since the previous update.
/// </summary>
/// <param name="keyboardDevice">The keyboard</param>
/// <param name="key">The key</param>
/// <returns><c>true</c> if the specified key is released; otherwise, <c>false</c>.</returns>
public static bool IsKeyReleased(this IKeyboardDevice keyboardDevice, Keys key)
{
return keyboardDevice.ReleasedKeys.Contains(key);
}
/// <summary>
/// Determines whether the specified key is being pressed down
/// </summary>
/// <param name="keyboardDevice">The keyboard</param>
/// <param name="key">The key</param>
/// <returns><c>true</c> if the specified key is being pressed down; otherwise, <c>false</c>.</returns>
public static bool IsKeyDown(this IKeyboardDevice keyboardDevice, Keys key)
{
return keyboardDevice.DownKeys.Contains(key);
}
}
}