Browse Subversion Repository
Contents of /NeoFT/Win32Util/Keyboard.cs
Parent Directory
| Revision Log
| 1 |
using System; |
| 2 |
using System.Runtime.InteropServices; |
| 3 |
|
| 4 |
namespace nft.win32util |
| 5 |
{ |
| 6 |
/// <summary> |
| 7 |
/// Keyboard-related utility functions |
| 8 |
/// </summary> |
| 9 |
public class Keyboard |
| 10 |
{ |
| 11 |
[DllImport("User32.dll")] |
| 12 |
private static extern short GetAsyncKeyState( int vKey ); |
| 13 |
|
| 14 |
// virtual key code (see Platform SDK) |
| 15 |
private const int VK_LEFT = 0x25; |
| 16 |
private const int VK_UP = 0x26; |
| 17 |
private const int VK_RIGHT = 0x27; |
| 18 |
private const int VK_DOWN = 0x28; |
| 19 |
private const int VK_SHIFT = 0x10; |
| 20 |
private const int VK_CONTROL = 0x11; |
| 21 |
|
| 22 |
public static bool isShiftKeyPressed { |
| 23 |
get { |
| 24 |
return GetAsyncKeyState(VK_SHIFT)<0; |
| 25 |
} |
| 26 |
} |
| 27 |
|
| 28 |
public static bool isControlKeyPressed { |
| 29 |
get { |
| 30 |
return GetAsyncKeyState(VK_CONTROL)<0; |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
} |
|