using multiple keyboard inputs simultaneously

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.

답변 (1개)

Geoff Hayes
Geoff Hayes 2020년 4월 21일
편집: Geoff Hayes 2020년 4월 21일

0 개 추천

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

No modifiers, I'm pressing things keys like 'a' and 'b' at the same time.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Desktop에 대해 자세히 알아보기

제품

질문:

2020년 4월 21일

댓글:

2020년 4월 21일

Community Treasure Hunt

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

Start Hunting!

Translated by