---
tags:
    - "Button"
    - "Analog"
    - "Amount"
    - "Press"
---

# Keyboard Key Value

[Input](index.md) / **Keyboard Key Value**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns the analog value of the specified Keyboard key

## Parameters

| Name | Description |
| :--- | :---------- |
| Key | The Keyboard key that is read |

## Code

```cs
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;
    }
}

```

