Documentation index for AI agents (llms.txt) A Markdown version of every page is available: request the page's source under /docs/, follow the "alternate" link in this page's head, or start from /llms.txt.
Visual Script logo Manual

Keyboard Key Value#

Input / Keyboard Key Value

  • Can Read

  • Cannot Write

Description#

Returns the analog value of the specified Keyboard key

Parameters#

Name Description
Key The Keyboard key that is read

Code#

using System;
using UnityEngine;
using UnityEngine.InputSystem;
using VisualScript.Icons;

namespace VisualScript.Runtime
{
    [Get]

    [Inline(nameof(m_Key))]

    [Title("Keyboard Key Value")]
    [Category("Input/Keyboard Key Value")]

    [Description("Returns the analog value of the specified Keyboard key")]
    [Image(typeof(IconKey), ColorTheme.Type.Blue, typeof(BadgeDot))]

    [Parameter("Key", "The Keyboard key that is read")]

    [Keywords("Button", "Analog", "Amount", "Press")]

    [Serializable]
    public class TypeNumberInputKeyboardValue : TypeNumber
    {
        [SerializeField] private Key m_Key = Key.Space;

        public override double Get(Args args)
        {
            Keyboard keyboard = Keyboard.current;
            return keyboard != null ? keyboard[this.m_Key].ReadValue() : 0d;
        }

        public override string ToString()
        {
            return $"Key {this.m_Key} Value";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.