# CursorLockMode

> How the cursor should behave.

## Definition

* **Type:** Enum
* **Namespace:** [UnityEngine](/engine/6000.6/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public enum CursorLockMode
```

## Remarks

These are various modes that control the behaviour of the Cursor. A default cursor must be set in **PlayerSettings** > **Default Cursor**.

## Examples

```csharp
//This script makes Buttons that control the Cursor's lock state. Note that the Confined mode only works on Windows and Linux Standalone platform build.

using UnityEngine;

public class Example : MonoBehaviour
{
    void Update()
    {
        //Press the space bar to apply no locking to the Cursor
        if (Input.GetKey(KeyCode.Space))
            Cursor.lockState = CursorLockMode.None;
    }

    void OnGUI()
    {
        //Press this button to lock the Cursor
        if (GUI.Button(new Rect(0, 0, 100, 50), "Lock Cursor"))
        {
            Cursor.lockState = CursorLockMode.Locked;
        }

        //Press this button to confine the Cursor within the screen
        if (GUI.Button(new Rect(125, 0, 100, 50), "Confine Cursor"))
        {
            Cursor.lockState = CursorLockMode.Confined;
        }
    }
}
```

## Fields

| Value                                                                              | Description                                      |
| ---------------------------------------------------------------------------------- | ------------------------------------------------ |
| [Confined](/engine/6000.6/script-reference/unityengine/cursorlockmode/confined.md) | Confine cursor to the game window.               |
| [Locked](/engine/6000.6/script-reference/unityengine/cursorlockmode/locked.md)     | Locks the cursor to the center of the Game view. |
| [None](/engine/6000.6/script-reference/unityengine/cursorlockmode/none.md)         | Cursor behavior is unmodified.                   |
