---
tags:
    - "Keyboard"
    - "Mouse"
    - "Gamepad"
    - "Touch"
    - "Pen"
    - "Plugged"
---

# Is Device Connected

[Input](index.md) / **Is Device Connected**

<div class="grid cards" markdown>

* :green_circle: Can Read

* :red_circle: Cannot Write

</div>

## Description

Returns true if the specified type of input device is available

## Parameters

| Name | Description |
| :--- | :---------- |
| Device | The type of input device that is checked |

## Code

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

namespace VisualScript.Runtime
{
    [Get]

    [Inline(nameof(m_Device))]

    [Title("Is Device Connected")]
    [Category("Input/Is Device Connected")]

    [Description("Returns true if the specified type of input device is available")]
    [Image(typeof(IconComputer), ColorTheme.Type.Blue)]

    [Parameter("Device", "The type of input device that is checked")]

    [Keywords("Keyboard", "Mouse", "Gamepad", "Touch", "Pen", "Plugged")]

    [Serializable]
    public class TypeBoolInputDeviceConnected : TypeBool
    {
        [SerializeField] private InputDeviceType m_Device = InputDeviceType.Gamepad;

        public override bool Get(Args args)
        {
            return this.m_Device switch
            {
                InputDeviceType.Keyboard => Keyboard.current != null,
                InputDeviceType.Mouse => Mouse.current != null,
                InputDeviceType.Gamepad => Gamepad.current != null,
                InputDeviceType.Touchscreen => Touchscreen.current != null,
                InputDeviceType.Pen => Pen.current != null,
                _ => throw new ArgumentOutOfRangeException()
            };
        }

        public override string ToString()
        {
            return $"{this.m_Device} is Connected";
        }

        protected override SubscriptionMode Subscription => SubscriptionMode.OnChange;
    }
}

```

