Skip to content
Advertisement

JavaScript onkeydown, return true,false

I am studying Javascript and I am at this simple code:Link, I understand this code but the only thing that I don’t understand is the return false.

I tried return true, and even I deleted the return line, and looked at FireFox, Chrome, and IE, and three of them didn’t look like something happened so if some one can please tell me what difference does it make if I put true, false or delete the return.

Advertisement

Answer

From code, I think there are mistake something. It would be…

function keyHit(evt) {

    ...

    if (thisKey == ltArrow) {
        chgSlide(-1);
    }
    else {
        if (thisKey == rtArrow) {
            chgSlide(1);
        }
    }
    return false;
}
function chgSlide(direction) {
        ...
}

And “return false” do nothing.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement