File Exchange

image thumbnail

Determine whether a key is up or down

version 1.0.0.0 (1.41 KB) by Mario Koddenbrock
Determines whether a key is up or down at the time the function is called

3 Downloads

Updated 11 Sep 2017

View License

Determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
So you don't need to use maltlab 'WindowButtonDownFcn' or 'java KeyPressedCallback'
VirtualKeyCode is an enumeration class for all the different keys and buttons.
See the following link for further information: https://msdn.microsoft.com/de-de/library/windows/desktop/dd375731(v=vs.85).aspx

Examples:

check mouse buttons:
mouseL = getAsyncKeyState(VirtualKeyCode.VK_LBUTTON);
mouseM = getAsyncKeyState(VirtualKeyCode.VK_MBUTTON);
mouseR = getAsyncKeyState(VirtualKeyCode.VK_RBUTTON);

check modifiers:
control = getAsyncKeyState(VirtualKeyCode.VK_CONTROL);
alt = getAsyncKeyState(VirtualKeyCode.VK_MENU);

Inspired by "ismousedpressed" [ https://de.mathworks.com/matlabcentral/fileexchange/61976-check-if-mouse-button-is-pressed?focused=7350547&tab=function ]

Comments and Ratings (0)

Updates

1.0.0.0

changed title

MATLAB Release Compatibility
Created with R2017a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired by: Check if mouse button is pressed