Skip to content Skip to sidebar Skip to footer

Listening To The Keypressed Event, Razor

@if (Model.HasPreviousPhoto)

Solution 1:

You will need to add a snippet of js in the view

<script>
    document.addEventListener('keydown', function(e){
        //37 is left arrow, 39 is right arrow
        if(e.which === 37){
            document.getElementById('previousPhoto').getElementsByTagName('a')[0].click();
        } else if (e.which === 39) {
            document.getElementById('nextPhoto').getElementsByTagName('a')[0].click();

    }
});

</script>

Post a Comment for "Listening To The Keypressed Event, Razor"