Form1.onkeypress() doesn't appear to work

I’ve set a timer (SetInterval) that causes some backroundColor changes for plain old Label controls.

I want to be able to clear the timer (ClearInterval) by pressing the spacebar when the form is displayed.

The Form1.onkeypress() event would seem to be the way to go, but when I put everything in motion, pressing the spacebar has no effect on the timer.

Any suggestions?

Thanks,
Ken

This event has evolved over the years.

onkeypress has been deprecated in most browers. The suggested replacement is onkeydown.
Keyboard events are only generated by <input> , <textarea> , <summary> and anything with the contentEditable or tabindex attribute. If not caught, they bubble up the DOM tree until they reach Document.

Try this:

document.onkeydown=function(){
  console.log("onkeypress");
}

More here.

Hi George,

Is there a Basic version of this?

It’s interesting that implementing this behavior using a BS4 Label or TextArea seems to work fine - the Form.onkeypress catches the spacebar press. Unfortunately, I have trouble making the BS4 Label.style.color property work properly and I can’t figure out how to change the background of the TextArea control (hence reviving the other thread). I also want a control that can’t be typed into and I still can control the text and background colors. The old label control had all that going for it.

Thanks,
Ken

Function document_onkeydown()
  console.log("onkeypress");
End Function

Bootstrap discourages modifying the colors of controls individually. It encourages having all the controls share a single set of rules for appearance, called a Theme. AppStudio has 22 Bootstrap themes built into it - you can set the theme in Project Properties - Frameworks - BootstrapTheme.

You can also customize your own theme.

Interesting… I’m trying to implement a UI prototype that simulates an option scanning interface for selecting a particular option by people with motor disabilities. I’m attempting to do that by sequentially changing the background color of a set of controls that can hold text (that isn’t editable). If you think I should be taking a different approach, I’m all ears.

In the real world, the selection would be by pressing a simple switch and triggering a feature of iOS or Windows (not pressing a key on the keyboard). Right now, I don’t have a clue how to make that work with NSB.

Thanks,
Ken

What do you mean by “simple switch”?

Is there a some action which, upon completion, triggers the next phase and a new color?

This page describes switch scanning (https://www.indigosolutions.org.au/docs/default-source/unlocking-abilities/switching-resources/introduction-to-switch-scanning.pdf?sfvrsn=13010064_4).

iOS supports connecting a Bluetooth switch like this one (Bluetooth Enabled Wireless iPad Switch - FREE Shipping), but there are interface devices that can take a simple pressure switch circuit closure (Switch It Up! Adaptive Switch | TFH Special Needs Toys USA) and communicate that to the iPad (or Windows) tablet as well.

The switch only makes the selection. The sequential highlighting is managed by the program.

I think your last message is badly formatted - was there supposed to be a link?

Yes there were 3. Maybe this will work better…

This page describes switch scanning:

iOS supports connecting a Bluetooth switch like this one:

but there are interface devices that can take a simple pressure switch circuit closure:

and communicate that to the iPad (or Windows) tablet as well. The switch only makes the selection. The sequential highlighting is managed by the program.

Thank you! The issue here will be to find a way to get you app to recognize the signal from the adaptive switch. It may be able to function as a keyboard wedge, which I think it what you’re hoping for: sending characters to your app as if they had come from the keyboard. The signal could also come in as a Bluetooth signal, in which case you’ll need to run as a native app and use a Bluetooth plugin.

You’ll need to dig into the interface to see what works.