Hello,
I would like to use the keyboard widget in toggle mode. However I would like a new key to toggle off any key previously switched on. Is it possible? With scripting maybe?
Hello,
I would like to use the keyboard widget in toggle mode. However I would like a new key to toggle off any key previously switched on. Is it possible? With scripting maybe?
A bit tricky, but possible:
var keyVal = value[getIndex(id)]
if (keyVal == getProp('this', 'on')) {
// if key is pressed
if (locals.lastKey) {
// release last pressed key
// sync:false to prevent forced release from triggering the script
set(locals.lastKey, 0, {sync:false})
}
// store pressed key
locals.lastKey = id
} else if (id == locals.lastKey ) {
// if key is released manually
locals.lastKey = 0
}
Brilliant! Thanks a lot @jean-emmanuel !