PennController for IBEX › Forums › Support › Enabling a button after text is entered without pressing Enter › Reply To: Enabling a button after text is entered without pressing Enter
September 21, 2020 at 3:24 pm
#6139
Jeremy
Keymaster
Hello,
Since I haven’t implemented a callback command for the TextInput element that would listen to keypresses, the best solution is to use a Key element (for which there is a callback command) to listen to keypresses. Now, it reacts to keypresses so fast that immediately checking the value of the TextInput element in the callback block won’t capture the newly pressed key, so you want to add a slight delay, e.g. 5ms before checking it.
Here’s how to do it based on the example you give:
newTrial('test', newTextInput('test_input') .print() , // empty string means any key newKey('').callback( newTimer(5).start().wait() , getTextInput('test_input').test.text(/\w/) .success( getButton('Next').enable() ) .failure( getButton('Next').disable() ) ) , newButton('Next', 'Next') .print() .disable() .wait() )
Let me know if you have any questions
Jeremy