Is there any way to trigger visibility based on key press?

Put your questions here on how to do things in ProtoShare.
Aki
Posts: 2
Joined: Fri Jan 25, 2013 1:42 am

Is there any way to trigger visibility based on key press?

Postby Aki » Fri Jan 25, 2013 1:44 am

I'm looking for something that compares to onKeyPress in basically every scripting language there is. I want my reviewer to hit a certain key, and when that key is pressed, show the active hotspots on the page.

Nick Jennings
Posts: 165
Joined: Mon May 14, 2012 12:06 pm

Re: Is there any way to trigger visibility based on key press?

Postby Nick Jennings » Mon Jan 28, 2013 11:51 am

Hi Aki,

Could you clarify a bit more about what you are trying to create?

You can use the Advance HTML component and Javascript to change a state's value and toggle the visibility of a component when the Advance HTML component is selected and a specific key is pressed. You can then change that component to look like a highlight for the clickable areas (Example: A box with a yellow fill and 50% opacity), simulating a hotspot. This sounds similar to what you are referring to, but the functionality is different.
Attachments
hotspotsim.png
hotspotsim.png (11.1 KiB) Viewed 6329 times
Nick Jennings
customerservice@protoshare.com
Site9, Inc. / Customer Support
blog.protoshare.com | twitter.com/protoshare

Aki
Posts: 2
Joined: Fri Jan 25, 2013 1:42 am

Re: Is there any way to trigger visibility based on key press?

Postby Aki » Mon Jan 28, 2013 8:24 pm

That means the active HTML component has to be selected in order for the keypress to be captured by it. Maybe I can get around that. Do you have any reference or docs for the StateMgr or an API of any kind?

Nick Jennings
Posts: 165
Joined: Mon May 14, 2012 12:06 pm

Re: Is there any way to trigger visibility based on key press?

Postby Nick Jennings » Tue Jan 29, 2013 10:29 am

Hi Aki,

Here is the code used to simulate what is shown in the screenshot:

Code: Select all

<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function show() {
thisKey = window.event.keyCode;
if (thisKey == 192) {
top.site9.StateMgr.set( 'ps', ['456:1'] );
}
}

function hide() {
thisKey = window.event.keyCode;
if (thisKey == 192) {
top.site9.StateMgr.set( 'ps', ['456:0'] );
}
}
</script>
</head>
<body onkeydown="show()" onkeyup="hide()">

<p>Click here, then press the ~` key.</p>

</body>
</html>
Pressing the ~ key changes the state with the ID of 456 to have a value of 1 from the default (0), which is the same thing as having a state with default values change from Off (0) to On (1). You can find the IDs for state from within the listing.

Hope this helps you out.
Nick Jennings
customerservice@protoshare.com
Site9, Inc. / Customer Support
blog.protoshare.com | twitter.com/protoshare


Return to “How Do I...”

Who is online

Users browsing this forum: No registered users and 3 guests

cron