using NativeEngine;
namespace Sandbox;
public static partial class Input
{
public static partial class Keyboard
{
///
/// Keyboard key is held down
///
public static bool Down( string keyName )
{
if ( Application.IsHeadless ) return false;
if ( Suppressed ) return false;
var code = NativeEngine.InputSystem.StringToButtonCode( keyName );
if ( code == ButtonCode.BUTTON_CODE_INVALID ) return false;
return CurrentContext.KeysCurrent.Contains( code );
}
///
/// Keyboard key wasn't pressed but now it is
///
public static bool Pressed( string keyName )
{
if ( Application.IsHeadless ) return false;
if ( Suppressed ) return false;
var code = NativeEngine.InputSystem.StringToButtonCode( keyName );
if ( code == ButtonCode.BUTTON_CODE_INVALID ) return false;
return !CurrentContext.KeysPrevious.Contains( code ) && Down( keyName );
}
///
/// Keyboard key was pressed but now it isn't
///
public static bool Released( string keyName )
{
if ( Application.IsHeadless ) return false;
if ( Suppressed ) return false;
var code = NativeEngine.InputSystem.StringToButtonCode( keyName );
if ( code == ButtonCode.BUTTON_CODE_INVALID ) return false;
return CurrentContext.KeysPrevious.Contains( code ) && !Down( keyName );
}
}
}