# UserInputService

UserInputService : `Instance`

## Overview

사용자의 장치에서 발생하는 입력을 감지할 수 있도록 도와주는 클라이언트 전용 서비스입니다.

키보드, 마우스, 터치스크린 등 입력 장치에 따라 동작을 다르게 처리할 수 있어 플랫폼에 최적화된 사용자 경험을 구현할 수 있습니다.

이 서비스는 LocalScript와 같은 클라이언트 환경에서만 사용할 수 있습니다.

## Properties

## Methods

## Events

### InputBegan

사용자가 화면을 클릭하거나, 마우스, 키보드 등으로 입력을 시작할 때 발생하는 이벤트입니다.

InputChanged와 InputEnded와 함께 사용하면, 입력의 시작부터 이동, 종료까지의 전체 과정을 효과적으로 추적할 수 있습니다.

다만, 모바일 환경에서는 사용을 권장하지 않으며, 스튜디오에서의 테스트나 시뮬레이션 용도로 사용하는 것이 적합합니다. 모바일 환경에서는 TouchStarted, TouchMoved, TouchEnded 이벤트를 사용하는 것이 권장됩니다.

#### Parameters

| `InputObject` InputObject | <p>입력과 관련된 세부 정보를 포함하는 객체이며,<br>하나의 입력이 시작되고 끝날 때까지 동일한 인스턴스로 유지됩니다.</p><ul><li><code>Enum.KeyCode</code> KeyCode: 입력된 키</li><li><code>Enum.UserInputState</code> UserInputState: 입력 상태</li><li><code>Enum.UserInputType</code> UserInputType: 입력 장치 종류</li><li><code>Vector3</code> Delta: 이동 변화량 (Z값은 0으로 고정)</li><li><code>Vector3</code> Position: 입력이 발생한 화면상의 위치 (Z값은 0으로 고정)</li></ul> |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool` bGameProcessed     | <p>해당 입력이 화면 상의 UI 요소에 의해 이미 처리되었는지를 나타냅니다.<br>입력에 영향을 줄 수 있는 UI는 다음과 같습니다:</p><ul><li>채팅창, 메뉴 버튼 같은 시스템 UI</li><li>ContextActionService로 Bind된 버튼</li><li>ScreenGui, SurfaceGui내 Active가 켜진 Gui 버튼</li></ul>                                                                                                                                                                                 |

#### 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
end
UserInputService.InputBegan:Connect(OnScreenTouchStart)
```

### InputChanged

사용자가 화면을 클릭한 상태에서 마우스 커서를 움직일 때 발생하는 이벤트입니다

마우스 커서가 어느 위치로 이동하고 있는지를 실시간으로 추적할 수 있어, 드래그, 스와이프와 같은 제스처 기반 입력을 감지하는 데 유용합니다.

다만, 모바일 환경에서는 사용을 권장하지 않으며, 스튜디오에서의 테스트나 시뮬레이션 용도로 사용하는 것이 적합합니다. 모바일 환경에서는 TouchStarted, TouchMoved, TouchEnded 이벤트를 사용하는 것이 권장됩니다.

#### Parameters

| `InputObject` InputObject | <p>입력과 관련된 세부 정보를 포함하는 객체이며,<br>하나의 입력이 시작되고 끝날 때까지 동일한 인스턴스로 유지됩니다.</p><ul><li><code>Enum.KeyCode</code> KeyCode: 입력된 키</li><li><code>Enum.UserInputState</code> UserInputState: 입력 상태</li><li><code>Enum.UserInputType</code> UserInputType: 입력 장치 종류</li><li><code>Vector3</code> Delta: 이동 변화량 (Z값은 0으로 고정)</li><li><code>Vector3</code> Position: 입력이 발생한 화면상의 위치 (Z값은 0으로 고정)</li></ul> |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool` bGameProcessed     | <p>해당 입력이 화면 상의 UI 요소에 의해 이미 처리되었는지를 나타냅니다.<br>입력에 영향을 줄 수 있는 UI는 다음과 같습니다:</p><ul><li>채팅창, 메뉴 버튼 같은 시스템 UI</li><li>ContextActionService로 Bind된 버튼</li><li>ScreenGui, SurfaceGui내 Active가 켜진 Gui 버튼</li></ul>                                                                                                                                                                                 |

#### Code Samples

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

local function OnScreenTouchMove(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position
end
UserInputService.InputChanged:Connect(OnScreenTouchMove)
```

### InputEnded

사용자가 화면 클릭, 마우스, 키보드 등의 입력을 종료할 때 발생하는 이벤트입니다.

이 이벤트는 입력의 종료 시점을 감지하는 데 사용됩니다.

다만, 모바일 환경에서는 사용을 권장하지 않으며, 스튜디오에서의 테스트나 시뮬레이션 용도로 사용하는 것이 적합합니다. 모바일 환경에서는 TouchStarted, TouchMoved, TouchEnded 이벤트를 사용하는 것이 권장됩니다.

#### Parameters

| `InputObject` InputObject | <p>입력과 관련된 세부 정보를 포함하는 객체이며,<br>하나의 입력이 시작되고 끝날 때까지 동일한 인스턴스로 유지됩니다.</p><ul><li><code>Enum.KeyCode</code> KeyCode: 입력된 키</li><li><code>Enum.UserInputState</code> UserInputState: 입력 상태</li><li><code>Enum.UserInputType</code> UserInputType: 입력 장치 종류</li><li><code>Vector3</code> Delta: 이동 변화량 (Z값은 0으로 고정)</li><li><code>Vector3</code> Position: 입력이 발생한 화면상의 위치 (Z값은 0으로 고정)</li></ul> |
| ------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool` bGameProcessed     | <p>해당 입력이 화면 상의 UI 요소에 의해 이미 처리되었는지를 나타냅니다.<br>입력에 영향을 줄 수 있는 UI는 다음과 같습니다:</p><ul><li>채팅창, 메뉴 버튼 같은 시스템 UI</li><li>ContextActionService로 Bind된 버튼</li><li>ScreenGui, SurfaceGui내 Active가 켜진 Gui 버튼</li></ul>                                                                                                                                                                                 |

#### Code Samples

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

local function OnScreenTouchEnd(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position
end
UserInputService.InputEnded:Connect(OnScreenTouchEnd)
```

### TouchEnded

사용자가 화면에서 손가락을 떼는 순간 발생하는 이벤트입니다.

이 이벤트는 터치 입력의 종료 시점을 감지하는 데 사용됩니다.

#### Parameters

| `InputObject` InputObject | <p>입력과 관련된 세부 정보를 포함하는 객체이며,<br>하나의 터치 입력이 시작되고 끝날 때까지 동일한 인스턴스로 유지됩니다.<br>따라서 멀티 터치의 경우, 이 객체들을 비교하는 방식으로 확인할 수 있습니다.</p><ul><li><code>Enum.KeyCode</code> KeyCode: 입력된 키</li><li><code>Enum.UserInputState</code> UserInputState: 입력 상태</li><li><code>Enum.UserInputType</code> UserInputType: 입력 장치 종류</li><li><code>Vector3</code> Delta: 이동 변화량 (Z값은 0으로 고정)</li><li><code>Vector3</code> Position: 입력이 발생한 화면상의 위치 (Z값은 0으로 고정)</li></ul> |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool` bGameProcessed     | <p>해당 입력이 화면 상의 UI 요소에 의해 이미 처리되었는지를 나타냅니다.<br>입력에 영향을 줄 수 있는 UI는 다음과 같습니다:</p><ul><li>채팅창, 메뉴 버튼 같은 시스템 UI</li><li>ContextActionService로 Bind된 버튼</li><li>ScreenGui, SurfaceGui내 Active가 켜진 Gui 버튼</li></ul>                                                                                                                                                                                                                                   |

#### Code Samples

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

local function OnScreenTouchEnd(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position
end
UserInputService.TouchEnded:Connect(OnScreenTouchEnd)
```

### TouchMoved

사용자가 화면 위에서 손가락을 움직일 때 발생하는 이벤트입니다.

손가락이 어느 위치로 이동하고 있는지를 실시간으로 추적할 수 있어, 드래그, 스와이프와 같은 제스처 기반 입력을 감지하는 데 유용합니다.

#### Parameters

| `InputObject` InputObject | <p>입력과 관련된 세부 정보를 포함하는 객체이며,<br>하나의 터치 입력이 시작되고 끝날 때까지 동일한 인스턴스로 유지됩니다.<br>따라서 멀티 터치의 경우, 이 객체들을 비교하는 방식으로 확인할 수 있습니다.</p><ul><li><code>Enum.KeyCode</code> KeyCode: 입력된 키</li><li><code>Enum.UserInputState</code> UserInputState: 입력 상태</li><li><code>Enum.UserInputType</code> UserInputType: 입력 장치 종류</li><li><code>Vector3</code> Delta: 이동 변화량 (Z값은 0으로 고정)</li><li><code>Vector3</code> Position: 입력이 발생한 화면상의 위치 (Z값은 0으로 고정)</li></ul> |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool` bGameProcessed     | <p>해당 입력이 화면 상의 UI 요소에 의해 이미 처리되었는지를 나타냅니다.<br>입력에 영향을 줄 수 있는 UI는 다음과 같습니다:</p><ul><li>채팅창, 메뉴 버튼 같은 시스템 UI</li><li>ContextActionService로 Bind된 버튼</li><li>ScreenGui, SurfaceGui내 Active가 켜진 Gui 버튼</li></ul>                                                                                                                                                                                                                                   |

#### Code Samples

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

local function OnScreenTouchMove(input, _gameProcessed)
    local keyCode = input.KeyCode
    local inputState = input.UserInputState
    local inputType = input.UserInputType
    local delta = input.Delta
    local pos = input.Position
end
UserInputService.TouchMoved:Connect(OnScreenTouchMove)
```

### TouchStarted

사용자가 화면을 터치 할 때 발생하는 이벤트입니다.

터치 기반 인터랙션의 시작점을 감지하는 데 유용하며, TouchMoved와 TouchEnded와 함께 사용하면, 터치의 시작부터 이동, 종료까지의 전체 과정을 효과적으로 추적할 수 있습니다.

#### Parameters

| `InputObject` InputObject | <p>입력과 관련된 세부 정보를 포함하는 객체이며,<br>하나의 터치 입력이 시작되고 끝날 때까지 동일한 인스턴스로 유지됩니다.<br>따라서 멀티 터치의 경우, 이 객체들을 비교하는 방식으로 확인할 수 있습니다.</p><ul><li><code>Enum.KeyCode</code> KeyCode: 입력된 키</li><li><code>Enum.UserInputState</code> UserInputState: 입력 상태</li><li><code>Enum.UserInputType</code> UserInputType: 입력 장치 종류</li><li><code>Vector3</code> Delta: 이동 변화량 (Z값은 0으로 고정)</li><li><code>Vector3</code> Position: 입력이 발생한 화면상의 위치 (Z값은 0으로 고정)</li></ul> |
| ------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `bool` bGameProcessed     | <p>해당 입력이 화면 상의 UI 요소에 의해 이미 처리되었는지를 나타냅니다.<br>입력에 영향을 줄 수 있는 UI는 다음과 같습니다:</p><ul><li>채팅창, 메뉴 버튼 같은 시스템 UI</li><li>ContextActionService로 Bind된 버튼</li><li>ScreenGui, SurfaceGui내 Active가 켜진 Gui 버튼</li></ul>                                                                                                                                                                                                                                   |

#### 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
end
UserInputService.TouchStarted:Connect(OnScreenTouchStart)
```

## 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/userinputservice.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.
