MATLAB Example Code - keyHandlerRelease
The keyHanlderRelease captures the release of keys from the keyboard. It sets the global variable to zero to denote that a key is no longer being pressed.
Examples
Enable the key handler for capturing key releases
set(gcf,'KeyReleaseFcn','keyHandlerRelease');
Source Code
function keyHandlerRelease(src,evnt)
% usage: keyHandlerRelease (src, evnt)
% purpose: Capture keystroke releases from the keyboard
global gCurrentKeyPress
%disp('Invoked release key handler');
clear global gCurrentKeyPress;
gCurrentKeyPress = 0;
% disp(y);
% disp(evnt.Character);
end
Other Notes
- It does not prevent the capture of multiple key strokes, i.e. if the key is still pressed multiple calls to isKeyPressed will still show that it is pressed.
Related Code / Code Dependencies