---
title: "GetButton y GetKey"
content_type: tutorial
url: "https://learn.unity.com/tutorial/getbutton-y-getkey?language=es"
language: es
difficulty: beginner
duration_minutes: 5
unity_version:
  - "2019.3"
  - "2019.2"
  - "2019.1"
  - "2018.4"
  - "2018.3"
  - "2018.2"
  - "2018.1"
  - "2017.4"
  - "2017.3"
  - "2017.2"
  - "2017.1"
  - "5.x"
  - "4.x"
supported_unity_versions:
  - name: "2019.3"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2019.3"
  - name: "2019.2"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2019.2"
  - name: "2019.1"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2019.1"
  - name: "2018.4"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2018.4"
  - name: "2018.3"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2018.3"
  - name: "2018.2"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2018.2"
  - name: "2018.1"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2018.1"
  - name: "2017.4"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2017.4"
  - name: "2017.3"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2017.3"
  - name: "2017.2"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2017.2"
  - name: "2017.1"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=2017.1"
  - name: "5.x"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=5.x"
  - name: "4.x"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es&version=4.x"
available_languages:
  - name: "en"
    url: "https://learn.unity.com/tutorial/getbutton-and-getkey.md?language=en"
  - name: "es"
    url: "https://learn.unity.com/tutorial/getbutton-y-getkey.md?language=es"
  - name: "ja"
    url: "https://learn.unity.com/tutorial/input-kurasuno-getbutton-to-getkey-guan-shu.md?language=ja"
  - name: "ko"
    url: "https://learn.unity.com/tutorial/getbutton-mic-getkey.md?language=ko"
  - name: "zh-cn"
    url: "https://learn.unity.com/tutorial/getbutton-he-getkey.md?language=zh-cn"
last_updated: "2026-08-04T14:24:07.000Z"
---

# GetButton y GetKey

Aprende a leer entradas de botones y teclas en Unity y a ajustar los ejes de entrada con Unity Input Manager.

Este tutorial demuestra cómo obtener las entradas de un botón o de una tecla en un proyecto de Unity y cómo se comportan estos ejes o cómo pueden ser modificados usando el administrador de ingresos de Unity (Unity Input Manager).

Este tutorial está incluido en el proyecto [_Scripting_ para principiantes. ](https://learn.unity.com/project/scripting-para-principiantes)

Previo: [Destruir](https://learn.unity.com/tutorial/destruir?language=es&publish=true#)

Siguiente:  GetAxis

## 1. GetButton y GetKey

[Video](http://www.youtube.com/watch?v=-A7D5Rcumz4)

## **KeyInput**

```csharp
using UnityEngine;
using System.Collections;

public class KeyInput : MonoBehaviour
{
    public GUITexture graphic;
    public Texture2D standard;
    public Texture2D downgfx;
    public Texture2D upgfx;
    public Texture2D heldgfx;
    
    void Start()
    {
        graphic.texture = standard;
    }
    
    void Update ()
    {
        bool down = Input.GetKeyDown(KeyCode.Space);
        bool held = Input.GetKey(KeyCode.Space);
        bool up = Input.GetKeyUp(KeyCode.Space);
        
        if(down)
        {
            graphic.texture = downgfx;
        }
        else if(held)
        {
            graphic.texture = heldgfx;
        }
        else if(up)
        {
            graphic.texture = upgfx;
        }
        else
        {
            graphic.texture = standard; 
        }
        
        guiText.text = " " + down + "\n " + held + "\n " + up;
    }
}
```

## **ButtonInput**

```csharp
using UnityEngine;
using System.Collections;

public class ButtonInput : MonoBehaviour
{
    public GUITexture graphic;
    public Texture2D standard;
    public Texture2D downgfx;
    public Texture2D upgfx;
    public Texture2D heldgfx;
    
    void Start()
    {
        graphic.texture = standard;
    }
    
    void Update ()
    {
        bool down = Input.GetButtonDown("Jump");
        bool held = Input.GetButton("Jump");
        bool up = Input.GetButtonUp("Jump");
        
        if(down)
        {
            graphic.texture = downgfx;
        }
        else if(held)
        {
            graphic.texture = heldgfx;
        }
        else if(up)
        {
            graphic.texture = upgfx;
        }
        else
        {
            graphic.texture = standard;
        }
    
        guiText.text = " " + down + "\n " + held + "\n " + up;
    }
}
```
