Integer value casting to KeyCode enum in JS?

Version 1:

private var k : KeyCode;

function Start () {
    k = KeyCode.Backspace;
    print (k);      //outputs: Backspace
}

function Update () {
    if (Input.GetKey(k)
        print ("Got it");
}

Above one succeeds.

Version 2:

private var k : KeyCode;

function Start () {
    k = 1;
    print (k);      //outputs: 1
}

function Update () {
    if (Input.GetKey(k)
        print ("Got it");
}

And it never succeeds.

Any trying with "as", (KeyCode) 1, [1] fails... Did I overlooked something?

There isn't a key corresponding to the value 1.

If you want to check the value for the 1 key on the keyboard:

var i : int = KeyCode.Alpha1; //the 1 on the top row of the keyboard
print(i); //won't print out 1, it'll be 38 i think

But the question remains - why're you trying to use ints anyway?

Are you trying to get the '1 key on the alphanumeric keyboard' or the '1 key on the number pad'? Or whatever key that the integer 1 is assigned to? My guess is, that 1 (the integer) is some key (if any) other than '1'. Different OS's may use different keyboard mappings, which is why you should always use the enum values if you can (Alpha1 or Keypad1)

Huh, thank God, finally, I could close 4 Firefox each one with a minimum of 5 tabs. :) Originally I thought casting to KeyCode enumeration goes:

In the help listing the KeyCode enum the ID increments by one by line. But NO! There are left out integer values those aren't in the enum listing. Not every integer contained by KeyCode element values. This way

var k : KeyCode = 1;
print (k);

really outputs "1", BUT forexample

var k : KeyCode = 8;
print (k);

outputs Backspace.

I should know that... Now I do and never forget. :)

A little code at the end:

private var k : KeyCode;
private var i : int;

function Start () {
    for (i = 0; i < 100; i++) {
        k = i;
        print(i + " as KeyCode: " + k);
    }
}

I totally accept my answer. :) I hope it is useful for somebody else as well... Huh.