Looking to use my left and right keyboard arrow to trigger a link_to.
My view page has this:
#RootDiv
.nav-arrow
= link_to lightbox_trip_path(@prev), class: "lbPrev" do
<
.nav-arrow
= link_to lightbox_trip_path(@next), class: "lbNext" do
>
Here's the coffee script
$ ->
if ($("#RootDiv").is(":visible"))
$(document).keydown (e) ->
if e.which == 37
# left
$('a.lbLeft').trigger 'click'
else if e.which == 39
# right
$('a.lbNext').trigger 'click'
return
I want to be able to only use these left and right arrow key when the #RootDiv
is visible.