Hi,
I'm trying to detect if shift (or ctrl/alt) key is down when a hotspot is clicked. Is there any away to get at the JS mouseEvent shiftKey property?
Hi,
I'm trying to detect if shift (or ctrl/alt) key is down when a hotspot is clicked. Is there any away to get at the JS mouseEvent shiftKey property?
Hi,
add this action on your XML file:
<action name="shif_key_monitor" type="Javascript" devices="html5" autorun="onstart" ><![CDATA[
krpano.set("shift_down","false");
var setShiftDown = function(event){
if(event.keyCode === 16 || event.charCode === 16){
krpano.set("shift_down","true");
}
};
var setShiftUp = function(event){
if(event.keyCode === 16 || event.charCode === 16){
krpano.set("shift_down","false");
}
};
window.addEventListener? document.addEventListener('keydown', setShiftDown) : document.attachEvent('keydown', setShiftDown);
window.addEventListener? document.addEventListener('keyup', setShiftUp) : document.attachEvent('keyup', setShiftUp);
]]></action>
Display More
and you can use an action like this in your hotspot onclick:
<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:
and then be checked in the onclick event:
<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
in krpano version 1.21 it will be possible to access the original JS Events object
Thanks Klaus, that's really awesome news. Waiting for this new release then
Hi Klaus,
Can you give an approximately time for 1.21 edition?
It can be yearly payment SAAS model and we can help you for all development. If updates come quickly i think so many people will be happy for SAAS version.
Don’t have an account yet? Register yourself now and be a part of our community!