MATLAB Answers

Alice
0

Collecting a key press

Asked by Alice
on 3 Feb 2015
Latest activity Commented on by Alice
on 3 Feb 2015
I'm trying to collect key presses and I need to see which key they pressed but MATLAB keeps giving me the numerical code as opposed to the character. How do I get the character as output instead?

  0 Comments

Sign in to comment.

Tags

1 Answer

Niels
Answer by Niels
on 3 Feb 2015
 Accepted Answer

It would be good if you provide us with a snippet of the code you are using right now.
With the current information provided, I can suggest 2 things:
  • Convert the numeric value to a character using char()
  • Use get(gcf,'currentcharacter') to get the actual string

  1 Comment

Alice
on 3 Feb 2015
I've been using
[KeyIsDown, secs, KeyCode] = KbCheck;
response(i)=KbName(KeyCode);

Sign in to comment.