0

I have written a html+css+javascript application, which simulates a presentation software (like powerpoint, keynote, prezi or similar), because I wanted to create some custom effects that are hard to create in such tools.

When I use Powerpoint (on my Apple MacBook), it works perfect together with Apples Remote control (this guy: Apple Remote). A click on the right-arrow lets Powerpoint display the next slide (or the next animation within a slide) while a click on the left-arrows brings me back one step.

Now I want to use this remote control in exactly the same way within my web browser (I'm using Google Crome, but any browser will do), using JavaScript+jQuery.

My website-presentation already correctly reacts on the arrow-keys on my keyboard using these lines of code:

$('body').on('keydown',function(event) {
    event.preventDefault();
    oldframe = frame;
    if ( event.which == 37 ) {//left
        frame--;
    }
    if ( event.which == 38 ) {//up
        frame--;
    }
    if ( event.which == 39 ) {//right
        frame++;
    }
    if ( event.which == 40 ) {//down
        frame++;
    }
    if (frame < 0) {frame = 0;}
    if (frame > (frames.length - 1)) {frame = frames.length - 1;}
    if (oldframe != frame) {gotoFrame(frame);}
});

My Questions:

  1. Is it posible, to catch events form Apple Remote within a Webbrowser using JavaScript?
  2. If yes: How? (using Javascript + jQuery)

I just know, that Apple Remote doesn't fire keydown-events, nor does it fire click-events. I have no idea which kind of events it fires, and if the browser is even aware of them.

Hubert Schölnast
  • 8,341
  • 9
  • 39
  • 76
  • Given that your question seems to revolve around the apple remote, it would probably be helpful if this question was tagged with it, if that tag exists. – Taplar Sep 04 '19 at 19:01
  • 2
    You might also try `$(document.body).on('*', function(event){ console.log(event) });` and see if anything is written to the console when you click your remote buttons – Taplar Sep 04 '19 at 19:03
  • try what Taplar said, and if it doesn't work, try it again in Safari. your odds will be better using an apple developed browser. – I wrestled a bear once. Sep 04 '19 at 19:09
  • @Taplar: `'*'` seems to be not a valid event class. You line is valid JavaScript code, and it works if I replace the asterisk with terms like `'keydown'` or `'click'`, but it doesn't react to anything when it is just `'*'`. (In Google Crome as well as Safari.) – Hubert Schölnast Sep 04 '19 at 19:25
  • If it works with PowerPoint then at least at the OS level you can capture its events. I would try it in Google Slides to see if it works there as well. If the browser doesn't get any of the events, you'd have to write something custom that forwards the events to the browser. I had to do this once for a trackpad device and made a server that communicated with the browser via WebSockets. – skyline3000 Sep 04 '19 at 21:02

0 Answers0