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

  • 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

  • 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

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!