Help with using keys to activate scripts

In my game I am trying to make slow motion and from looking at unity’s manual I came up with this code but I keep getting an error saying Input Button KeyCode.F is not set up. I am new to using keys in my game so any help would be very appreciated. (The codes a js)

function Update()
{
    if(Input.GetButtonDown("KeyCode.F"))
    {
        Time.timeScale = 0.5f; // 50% slower
    }
}

I think you are looking for Input.GetKeyDown("f"), if I understand what you are trying to do (go in slow motion when ‘f’ is pressed). If you add an input called “Slow Motion” to the input preferences, then you can use Input.GetButtonDown("Slow Motion"), and users will be able to rebind the slow motion key.

Should be fine if you get rid of the exclamation marks. So instead of

GetButtonDown("KeyCode.F")

use

GetButtonDown(KeyCode.F)

otherwise you’d be looking for a key called “Keycode.F” instead of “F”.