Trigger animation using bluetooth clicker

I am doing a prototype that controlled by a bluetooth clicker.I divided each animation in different scenes. Once I clicked the clicker ,scenes changes( animation change). My question is which behavior in the scenes tap should I use to be able to click back and force using bluetooth clicker? ( on Keep down? On keep up? )

I haven’t done this, so it’s just theoretical.

If the Bluetooth device uses the equivalent of keyboard arrow keys to go forwards or backwards, then it should just be a matter of detecting which key is pressed.

So, on key press, check the event to see which key was pressed. You need to know the key codes to know which key was pressed. I discuss this in my book, but it’s also discussed here…

So, the Bluetooth device could theoretically control a Hype project, similar to a PowerPoint / Keynote presentation.

Thank you! I think the clicker’s function is uses as page up page down on the “PPT”. I will try the solution above and see if it would work.

Thank you again!

I look through the link you sent me and still kinda confusing. Because I have limited knowledge on coding, I am wondering if you would like to make me a demo that something moves while press the key board up & down button. (maybe coded function?)

Thank you so much!

I'm a bit tired tonight, but I am considering it as the topic for the next Free Hype Template...

...but this is sorta covered in "A Book About Hype". The "Controlling" section shows how to make a little spaceship move around the screen with a 4-way (on-screen) controller. So, if I make a template, I want to make something unique – which respects the people that bought the book. (It doesn't use arrow keys though, so that is a big difference. The book was made to be compatible with iOS devices, which typically doesn't have a keyboard.)

There are already plenty of examples of the coding for this on the site.

http://forums.tumult.com/search?q=Arrow%20keys

1 Like

Wow, he's right...

Looks like I can relax this weekend. :smile:

1 Like

Thank you so much! The code is working. However, on my bluetooth clicker, the up and down key recognized as page down, page up on my MAC.( the page down/up key for mac is fn + up/down arrow key). I tried to modify the code to work for multiple key pressed but unfortunately it is no working.
here is the code I modified;

document.onkeydown = checkKey;

function checkKey(e) {

e = e || window.event;

if (e.keyCode == ‘38’ && e.keyCode == ‘63’) {
// up arrow
hypeDocument.showNextScene(hypeDocument.kSceneTransitionInstant);
}
else if (e.keyCode == ‘40’ && e.keyCode ==’ 63’) {
// down arrow
hypeDocument.showPreviousScene(hypeDocument.kSceneTransitionInstant);
}
}

Can you guys have a better solution on press multiply key?

Thank you!

Actually, I solved it. The page up/down keycode is 33 and 34.

Thank you again!

The arrow down and up key codes change to 34 & 33 when the fn key is down.

See you now have spotted that but since I was typing this…

document.onkeydown = checkKey;
function checkKey(e) {
e = e || window.event;
//console.log(e.keyCode);
if (e.keyCode == '40'  ||  e.keyCode == '34') {
  console.log("down arrow");
}
else if (e.keyCode == '38' ||  e.keyCode == '33') {
 
console.log("up arrow");
}
}

It is working with blew code as well;

I got one more question, when I was trying to change scenes, since I have a counting down clock on it, when the scenes changed the clock flashes, even I set the transition instant, do you know what to do to eliminate the flashing? ( the code for counting down clock;

body { margin:0px; padding:0px; } #txt { font:50px arial, sans-serif; text-align:center; color:#FCFFF4; }

code for page up/down

document.onkeydown = checkKey;

function checkKey(e) {

e = e || window.event;

if (e.keyCode == ‘33’) {
// up arrow
hypeDocument.showNextScene(hypeDocument.kSceneTransitionInstant);
}
else if (e.keyCode == ‘34’) {
// down arrow
hypeDocument.showPreviousScene(hypeDocument.kSceneTransitionInstant);
}
}

Thanks!

Without seeing an example it is hard to tell what is going on.
Can you post a project zip.

I am using company’s computer so I cannot upload anything online. I figured if I put all the interaction within one scene and trigger it with my bluetooth clicker, the clock on my animation would not flash. However, I do not know how to code JS that can play previous and next timeline works same as jump to previous/ next scene. So basically I just want to change the whole animation works scene to scene to working timeline to timeline.

If you know how to do this, please help me!
I appreciate your help!

Thank you!!

If there’s a way to upload or post a small example replicating the flashing that would be useful; unfortunately there’s no way to know without really looking at the document and seeing what is going on.