MATLAB Example - Key Handler Callback Function
Annotations
- Sets an element in the array to 1 for the key being pressed
- Allows for multiple key presses to be detected and polled for successfully
Raw Source Code
function keyHandlerPressAdv(src,evnt)
% usage: keyHandlerPress(src, evnt)
% purpose: Sets the global variable to reflect the current key press
global gCurrentKeyPress
key = get(gcf,'CurrentCharacter');
% Convert to an integer
key = key-0;
gCurrentKeyPress(key) = 1;
end