Shift key down? help

I am beyond confused. I have already searched through the ask questions and googled this problem, I can’t seem to get it to detect the shift key. The current script I am using is
if (Input.GetKeyDown(“shift”))
{
Debug.Log(“shift key was pressed”);
}

Unity recognizes "left shift" and "right shift", but not "shift".

Use something like this:

Input.GetKeyDown("left shift")

Or this:

Input.GetKeyDown(KeyCode.LeftShift)

To respond to either key, you can check both of them:

Input.GetKeyDown(KeyCode.LeftShift) || Input.GetKeyDown(KeyCode.RightShift)

You can find a full list of supported keys at the input manual page or KeyCode enum page.

Check: shift key input script - Unity Answers

In your update method, you can do this:

void Update()
{
    bool isShiftKeyDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
}

You need to use GetKey() instead of GetKeyDown(). The first one will return true if the shift key is down. The second one will return true only the moment the shift key is pressed (one frame).

There is no internal association with the Left/Right Shift keycode.


This is a confirmed bug by Unity. It has been in Unity since forever (pre-2010), but I reported it myself about two weeks ago.


It’s Impossible to check Event.current.keyCode using the “KeyCode.LeftShift” and “KeyCode.RightShift” representations of the object Enum. The Enum object exists, but the numerical value it was supposed to associate with “LeftShift” and “RightShift” objects (written in the Documenation) does not actually exist. The LeftControl and LeftAlt variations do work. It is only LeftShift/RightShift that doesn’t associate with anything that can be tested in “Event.current.keyCode”.

How you can reproduce it:

Easy – Just make a new project, make a new C# script called “TestKeycodes” then place it in an “Editor” folder, and finally, simply paste the following code into that new Editor Script:

using UnityEngine;
using UnityEditor;

[InitializeOnLoad]
[ExecuteInEditMode]
public class TestKeycodes : EditorWindow
{

    [InitializeOnLoadMethod]
    public static void InitTest()
    {
        SceneView.onSceneGUIDelegate -= OnGUI;
        SceneView.onSceneGUIDelegate += OnGUI;
    }

static void OnGUI()
{
Debug.Log(Event.current.keyCode);
}

}

Make sure your class runs in Edit Mode constantly and automatically!

Now run the script and watch the Console.

It will display “None” constantly in the console.
Press LeftControl or RightAlt or the “A” or “P” keys. You should see them registering in the Console.
Now Press LeftShift and RightShift however many times you want. You will see nothing about them appearing in the console no matter when or how you press them. This is because they don’t exist.