admin
Filed under - Development, JavaScript, jQuery
No Comments so far. Add yours now

Scroll Elements Horizontally with keyboard shortcode…

DEMO - http://jsfiddle.net/Kushal_Gandhi/DmFyN/

 

Selec All Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
$("body").keypress(function(e) {
    e.preventDefault();
    // alert(e.which);
    var pos = $('ul#scores').css('left');
    pos2 = pos.replace('px', '');
    pos3 = parseFloat(pos2) - parseFloat(120);
    pos4 = parseFloat(120) + parseFloat(pos2);
    //g == 103
    if (e.which == 103) {
        $('ul#scores').animate({
            'left': pos3
        }, {
            queue: false
        });
    }
    //h == 104
    if (e.which == 104) {
        if (pos4 <= 0) {
            $('ul#scores').animate({
                'left': pos4
            }, {
                queue: false
            });
        }
    }
    });

Tags: , , ,

Leave your comment

You must be logged in to post a comment.

Share IT © 2018. All rights reserved.