Link key-down state to event listener

3 views (last 30 days)
Elisa
Elisa on 12 Mar 2017
I have a code showing some circles and lines on the screen (I'm using PsychToolbox to display them, which also provides functions to detect key press events or keydown states).
I'd like to have a callback function (or an event listener) to respond to a keypress and (say) move a line vertically. Ideally, the line will stay put and the circles will bounce around while no key is down, but the line will move while a given key is down.
The reason I want to do this is because I'd like to use the keyboard to simulate input from an analog sensor that communicates via a USB-Data Acquisition box; and read into matlab with a callback function that updates a variable whenever a new data point is available.
I've found lots of answers in the forum about how to create keyboard event callbacks that are linked to GUIs. But that's not what I need. Is it possible to link a keypress event (or better yet, keydown state) to an event listener and if so, how?

Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!