0

Okay, so I need to create the code to ensure that when certain keys are pressed triggers the event as if a button were clicked. following the link through that button when they keyboard keys are pressed.

el.on('keypress', function(event){
    $('li').find('li.next');
        if (keycode == 39) {
            $('.next').click();
        }

});
el.on('keypress', function(event){
   $('li').find('li.prev');
        if (keycode == 37){
            $('.prev').click();

    }
});
  • if you want to trigger the click use $('.next').trigger('click'); – brk Oct 16 '15 at 11:08
  • what's the point of this line: `$('li').find('li.prev');` it doesn't seem to do anything. Also why don't you just try it to see if it works? – Pete Oct 16 '15 at 11:14
  • What is `el`? Where is the corresponding html? What link are you talking about .. `
  • ` is not a link. Please show all relevant html structure. Using `find()` looks very suspicious.
  • – charlietfl Oct 16 '15 at 11:27
  • basically, I have a next and a previous button in modals which I want to trigger when a user presses the right and left arrow key, – jonathan-opinurate Oct 16 '15 at 11:51
  • @charlietfl var el = this.element; – jonathan-opinurate Oct 16 '15 at 11:54