Detecting shift-clicks on hotspots

  • Hi,

    add this action on your XML file:

    and you can use an action like this in your hotspot onclick:

    Code
    <action name="onclickspotpoint90">
      if(shift_down=="true",
        trace(YES);
      ,
        trace(NO);
      );
    </action>

    I hope it can help you!

    Thanks,
    Hamid

  • Hi,

    krpano has build-in keyboard events, no need to use external JS here:
    https://krpano.com/docu/xml/#events.onkeydown

    The keycode variable always contains the key-code of the last pressed or last released key.

    With some custom code the current pressed key can be stored:

    Code
    <events onkeydown="copy(pressedkey, keycode);" 
            onkeyup="set(pressedkey,0);"
            />

    and then be checked in the onclick event:

    Code
    <hotspot
        ...
        onclick="if(pressedkey == 16, trace('shift-key pressed'); , trace('no shift-key pressed'); );"
        />

    The keycode for shift is 16, for ctrl 17 and for alt 18.

    Best regards,
    Klaus

  • Hi,

    thanks for your detailed help. Actually I was hoping for some flag inside the onclick handler, just like the native JS mouseEvent. Monitoring shift key presses might not always work: for example, what if it's pressed while the browser window does not have the focus and only then the hotspot is clicked?

  • Hi,

    in krpano version 1.21 it will be possible to access the original JS Events object when assigning the events to Javascript functions or Javascript actions. Then directly e.g. checking for the shiftKey property would be possible.

    Best regards,
    Klaus

Jetzt mitmachen!

Sie haben noch kein Benutzerkonto auf unserer Seite? Registrieren Sie sich kostenlos und nehmen Sie an unserer Community teil!