Keyboard Pressed this Frame#
Input / Keyboard Pressed this Frame
Can Read
Cannot Write
Description#
Returns true the frame the specified Keyboard key is pressed down
Parameters#
| Name | Description |
|---|---|
| Key | The Keyboard key that is checked |
Code#
using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;
namespace VisualScript.Runtime
{
[Get]
[Inline(nameof(m_Key))]
[Title("Keyboard Pressed this Frame")]
[Category("Input/Keyboard Pressed this Frame")]
[Description("Returns true the frame the specified Keyboard key is pressed down")]
[Image(typeof(IconKeyPress), ColorTheme.Type.Blue)]
[Parameter("Key", "The Keyboard key that is checked")]
[Keywords("Button", "Down", "Just", "Started")]
[Serializable]
public class TypeBoolInputKeyboardPressThisFrame : TypeBool
{
[SerializeField] private Key m_Key = Key.Space;
public override bool Get(Args args)
{
Keyboard keyboard = Keyboard.current;
return keyboard != null && keyboard[this.m_Key].wasPressedThisFrame;
}
public override string ToString()
{
return $"Pressed {this.m_Key}";
}
protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
}
}