-4

I created a flip book. How to add keyboard functions for turning pages??

Source code- https://github.com/Ananthavijay/News-Book

Preview- http://hardcore-morse-14df89.bitballoon.com/

2 Answers2

1

In Jquery, you can bind a keypress event to particular function like

$( "#target" ).keypress(function() {
console.log( "Handler for .keypress() called." );
});

if you want to bind the event to only a specific key for example left and right arrow keys;

$( "#target" ).keypress(function(event) {
  if(event.which === 37 ){ //for left arrow key
     console.log( "Handler for .keypress() called." );
   }
});

Check out more key codes here

Shubham Shukla
  • 206
  • 1
  • 5
0

How to use keys "left", "right", "top", "bottom":

Detecting arrow key presses in JavaScript

You can use it with document.addEventListener('keydown', function(e){ // your code })

Artem
  • 71
  • 4