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

On Keyboard Press#

Input / Keyboard / On Keyboard Press

Description#

Executes when the Keyboard key is pressed down

Code#

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

namespace VisualScript.Runtime
{
    [Title("On Keyboard Press")]
    [Image(typeof(IconKey), ColorTheme.Type.Blue, typeof(BadgeArrowDown))]
    
    [Description("Executes when the Keyboard key is pressed down")]
    [Category("Input/Keyboard/On Press")]

    [Keywords("Button", "Down")]
    
    [Serializable]
    public class TriggerCoreInputKeyboardPress : TriggerHandleSubscriptionBase<HandleOnInputKeyboard>
    {
        // EXPOSED MEMBERS: -----------------------------------------------------------------------

        [SerializeField] private Key m_Key = Key.Space; 
        
        // PROPERTIES: ----------------------------------------------------------------------------

        protected override string GetTitle(GameObject source)
        {
            string key = TextUtils.Humanize(this.m_Key);
            return $"Press {TextUtils.ThemeAsKeyword(key)}";
        }

        // OVERRIDE METHODS: ----------------------------------------------------------------------
        
        protected override void OnTrigger(GameObject target)
        {
            if (!Keyboard.current[this.m_Key].wasPressedThisFrame) return;
            
            using Args args = Args.Get(this.Component, target);
            this.Run(args);
        }
    }
}
Visual Script logoVisual Script © Catsoft Works 2026. All rights reserved.