# InputObject

InputObject : `Instance`

## Overview

화면 터치나 마우스, 키보드 입력 등 사용자 입력이 발생할 때 생성되는 객체입니다.

사용자의 입력 유형(UserInputType)와 입력 상태(UserInputState), 입력된 키(KeyCode)와 입력 위치(Position) 등의 속성을 통해 입력의 세부 사항을 확인할 수 있습니다.

이 객체는 다음과 같은 이벤트에서 생성됩니다:

* UserInputService의 TouchStarted, TouchMoved, TouchEnded
* UserInputService의 InputBegan, InputChanged, InputEnded
* ContextActionService의 BindAction()에 연결된 함수
* GuiButton의 InputBegan, InputChanged, InputEnded 이벤트

이 객체는 입력이 시작되는 시점부터 종료될 때까지 동일한 인스턴스로 유지되며, 입력 중 상태 변화는Changed 이벤트를 통해 감지할 수 있습니다. 이를 통해 현재 활성화된 입력들을 리스트로 관리하거나 해당 입력에 대해 계속 추적 및 제어할 수 있고, 모바일 환경에서 각 손가락 입력을 구분하여 처리할 수 있습니다.

InputObject는 UserInputService의 이벤트나 GuiObject의 입력 처리와 연계되어 사용됩니다.

## Properties

### Delta

`Vector3`

입력 위치의 변화량을 나타내는 값으로, Position 속성과 함께 사용하면 입력 경로를 추적할 수 있어 카메라 이동이나 캐릭터 조작과 같은 구현에서 유용하게 활용됩니다.

단, 키보드 입력처럼 위치 정보가 없는 입력 유형의 경우, Delta나 Position는 입력 시작 및 종료 이벤트에서만 확인할 수 있습니다.

#### Code Samples

```lua
local UserInputService = game:GetService("UserInputService")

local function OnScreenTouchStart(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position

    print("KeyCode : ", keyCode)
    print("InputState : ", inputState)
    print("InputType : ", inputType)
    print("Delta : ", delta)
    print("Position : ", pos)
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
```

### KeyCode

`Enum.KeyCode`

입력에 사용된 키 정보를 나타내는 값으로, 모바일 환경에서 터치 입력과 가상 조이스틱 입력을 구분하는 용도로도 활용할 수 있습니다.

#### Code Samples

```lua
local UserInputService = game:GetService("UserInputService")

local function OnScreenTouchStart(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position

    print("KeyCode : ", keyCode)
    print("InputState : ", inputState)
    print("InputType : ", inputType)
    print("Delta : ", delta)
    print("Position : ", pos)
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
```

### Position

`Vector3`

입력 위치를 나타내는 값으로, 마우스나 터치 입력시 X, Y 좌표는 화면상의 좌표를 의미합니다.

#### Code Samples

```lua
local UserInputService = game:GetService("UserInputService")

local function OnScreenTouchStart(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position

    print("KeyCode : ", keyCode)
    print("InputState : ", inputState)
    print("InputType : ", inputType)
    print("Delta : ", delta)
    print("Position : ", pos)
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
```

### UserInputState

`Enum.UserInputState`

입력의 진행 상태를 나타내는 값으로, 시작, 변경, 종료, 취소 등 상태를 구분하여 입력의 흐름을 추적하거나 상태에 따른 처리를 구현할 때 유용하게 활용됩니다.

#### Code Samples

```lua
local UserInputService = game:GetService("UserInputService")

local function OnScreenTouchStart(input, _gameProcessed)
    local inputState = input.UserInputState

    print("InputState : ", inputState) -- Begin
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)

local function OnScreenTouchMove(input, _gameProcessed)
    local inputState = input.UserInputState

    print("InputState : ", inputState) -- Change
end
UserInputService.TouchMoved:Connect(OnScreenTouchMove)

local function OnScreenTouchEnd(input, _gameProcessed)
    local inputState = input.UserInputState

    print("InputState : ", inputState) -- End
end
UserInputService.TouchEnded:Connect(OnScreenTouchEnd)
```

### UserInputType

`Enum.UserInputType`

입력의 종류를 나타내는 값으로, 터치, 키보드, 마우스 등 다양한 입력 방식을 구분할 수 있으며, KeyCode와는 별도로 입력 유형을 판별하는 데 사용됩니다.

#### Code Samples

```lua
local UserInputService = game:GetService("UserInputService")

local function OnScreenTouchStart(input, _gameProcessed)
    local inputType = input.UserInputType

    print("InputType : ", inputType) -- Touch
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
```

## Methods

## Events

## See also

{% content-ref url="/pages/KiXAGwJU8cox0tGXdepn" %}
[모바일 조작 처리](/korean/manual/script-manual/input-and-controls/contextactionservice.md)
{% endcontent-ref %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.overdare.com/korean/development/api-reference/classes/inputobject.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
