using multiple keyboard inputs simultaneously
Mostra commenti meno recenti
I trying to create a game in MATLAB that when it plays it requires you to use multiple keys on the keyboard, multiple keys must be pressed at the same time, I don't know how I would get this to work.
Risposte (1)
Geoff Hayes
il 21 Apr 2020
Modificato: Geoff Hayes
il 21 Apr 2020
Isaiah - what are the multiple keys that can be pressed? If one of the keys is the shift or command/control or alt, then that would appear as a "modifier" in the keypress eventdata:
function keyPressListener
hFig = figure;
hAxes = gca;
set(hFig,'WindowKeyPressFcn',@keyPressCallback);
function keyPressCallback(source,eventdata)
% eventdata has character, modifier, and key fields
eventdata
end
end
If I run the above code, and press (say) shift + a, then I would see
eventdata =
Character: 'A'
Modifier: {'shift'}
Key: 'a'
Note that this probably will only work if at least one of your keys is a modifier.
1 Commento
Isaiah Buell
il 21 Apr 2020
Categorie
Scopri di più su Desktop in Centro assistenza e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!