You are not logged in.

1

Tuesday, August 28th 2012, 1:34pm

beginner seeking help - onkeydown event

Hi,

I'm green in coding. Can anyone advise how can we initiate a certain action with a particular key, like the "H" key? I checked the doc and knowing there is a keycode variable, but don't know how to use it to check if the right key was pressed and kick off such action.

I found these in the doc, but dunno how to put them together:
<events onkeydown="showlog(); trace('keycode=',keycode);" />
if(condition, then-actions, else-actions*)

Thanks.
Ric

2

Tuesday, August 28th 2012, 2:06pm

Add something like this:

<!-- actionscript keyboard control -->

<action name="keydown-bed">
trace(keydown - keycode=,keycode);

if (keycode == 49, loadscene(pano3));
if (keycode == 50, loadscene(pano5));

if (keycode == 81, rotate-off);
if (keycode == 87, rotate-on);

</action>

Then in each pano call the action:

<events onkeydown="action(keydown-bed);" />

In this example '1' loads pano3, '2' loads pano5, 'q' and 'w' turn rotate off/on

cheers
Tim

3

Thursday, August 30th 2012, 5:05am

Hi Tim,

I've downloaded the sample zip file and added the followings in the tour.xml file:

<action name="keydown-bed">
trace('keycode=',keycode);
if (keycode == 49, loadscene(scene_galerie));
if (keycode == 50, loadscene(scene_werkstatt));
</action>

<events onxmlcomplete="set(plugin[loading].visible,true);"
onloadcomplete="set(plugin[loading].visible,false); fade_in_hotspots();"
onkeydown="action(keydown-bed);"
/>

however, there is nothing happen when I hit the 1 or 2 key. Did I made anything wrong *confused* ? thx

Regard,
Ric

4

Thursday, August 30th 2012, 1:19pm

Hi,

the posted xml code itself is okay...

best regards,
Klaus