17 lines
No EOL
431 B
C#
17 lines
No EOL
431 B
C#
namespace Domain.Input {
|
|
public abstract class InputReader {
|
|
private bool _wasPressed;
|
|
private bool _isPressed;
|
|
|
|
protected abstract int Key { get; }
|
|
|
|
public void UpdateInput() {
|
|
_wasPressed = _isPressed;
|
|
_isPressed = Win32API.GetAsyncKeyState(Key) != 0;
|
|
}
|
|
|
|
public bool KeyDown() => _isPressed && !_wasPressed;
|
|
public bool KeyPressed() => _isPressed;
|
|
public bool KeyUp() => !_isPressed && _wasPressed;
|
|
}
|
|
} |