Educational materials

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

r1 - 29 Aug 2007 - 17:27:15 - AaronStriegel
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Syndicate this site RSSATOM