Better jQuery function argument with if-statement? function check_itv(key) {

if (key.length){

    if(key=="left"){
        left_itv = setInterval(left,100);
        check_left= false;
        check_right=true;
        check_up=true;
        check_down=true;
        clearInterval(right_itv);
        clearInterval(down_itv);
        clearInterval(up_itv);
    }

    if(key=="right"){
        right_itv = setInterval(right,100);
        check_left= true;
        check_right=false;
        check_up=true;
        check_down=true;
        clearInterval(left_itv);
        clearInterval(down_itv);
        clearInterval(up_itv);
    }

    if(key=="up"){
        up_itv = setInterval(up,100);
        check_left= true;
        check_right=true;
        check_up=false;
        check_down=true;
        clearInterval(left_itv);
        clearInterval(right_itv);
        clearInterval(down_itv);
    }

    if(key=="down"){
        down_itv = setInterval(down,100);
        check_left= true;
        check_right=true;
        check_up=true;
        check_down=false;
        clearInterval(left_itv);
        clearInterval(right_itv);
        clearInterval(up_itv);
    }

}

}

check_left = true;
check_right = true;
check_up = true;
check_down = true;
left_itv = "";
right_itv = "";
up_itv = "";
down_itv = "";


Try to do shorter and better, Any idea ?

Thanks
Without changing too much, here are some tips on improving your code.
Assumptions:

You're working in modern web browser.
left, up, down, right are defined else where.

1)
Define all the variables at the top. I'm not sure where the fucntions left, up, down, right are.
2)
Use a switch instead of multiple if else.
3)
Perform an operation to collection if multiple elements share the same functionality. Refer to resetValues()
4)
Try to make all the if conditions as small as possible. Refer to !key.length
Here's what I came up with.
Array.prototype.forEach = Array.prototype.forEach || function(fn, scope) {
    for(var i = 0, len = this.length; i &lt; len; ++i) {
        fn.call(scope || this, this[i], i, this);
    }
};

var self = this,
    check_left, check_right, check_up, check_down,
    left_itv, right_itv, up_itv, down_itv;
    
var resetValues = function(){
    [&quot;left_itv&quot;, &quot;right_itv&quot;, &quot;up_itv&quot;, &quot;down_itv&quot;].forEach(function(el){
        clearInterval( self[el] );
    });
    [&quot;check_left&quot;, &quot;check_right&quot;, &quot;check_up&quot;, &quot;check_down&quot;].forEach(function(el){
        self[el] = true;
    });
};

resetValues();

function check_itv(key) {
    if (!key.length) {
        return;
    }
    resetValues();
    switch( key ){
        case &quot;left&quot;:
            left_itv = setInterval(left, 100);
            check_left = false;
            break;
        case &quot;right&quot;:
            right_itv = setInterval(right, 100);
            check_right = false;
            break;
        case &quot;up&quot;:
            up_itv = setInterval(up, 100);
            check_up = false;
            break;
        case &quot;down&quot;:
            down_itv = setInterval(down, 100);
            check_down = false;
    }
}

Alternatively, you could swap the global variables inside a singleton(namespace) that has a reset functions. But that add a bit of complexity.