Can I set Input.GetKey() as an variable so I could change the variable key to my liking from unity editor?

private void CheckInput2()
{
Vector3 posY = transform.position;
if (Input.GetKey(KeyCode.UpArrow))
{
posY.y += updownspeed2 * Time.deltaTime;
}
if (Input.GetKey(KeyCode.DownArrow))
{
posY.y -= updownspeed2 * Time.deltaTime;
}
transform.position = posY;
}

Could I make Input.GetKey(Keycode.DownArrow) as some serialised field variable, so I could access it from the unity editor.

Yup - like this:

[SerializeField] KeyCode keyCode;