문제

The console.log return this which looks like and array : keyup charCode=0, keyCode=18 But I tried event[1] to get the keycode but it's undefined, how do I extract the keycode from this ?

function processKeyDown(event)
{
    console.log(event);
}
도움이 되었습니까?

해결책

this is because event is an object, not an indexed based array. use event.keyCode instead.

다른 팁

Use event.keyCode to access the key that was pressed.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top