- ‘’KeyPressFcn” - Key-press callback can access specific information about the user’s interaction with the keyboard. You can refer to this link for more information: https://www.mathworks.com/help/matlab/ref/matlab.ui.figure-properties.html#buiwuyk-1-KeyPressFcn
- Hidden/unobtrusive figure window: The figure window can be made very small and positioned off-screen. However, completely hiding the figure (e.g., setting ‘Visible’, ‘off’) usually disables its ability to receive key press events. Here is the script that keeps the figure less obtrusive so that it doesn’t appear on the MATLAB window while capturing the key presses:
- Positioning Off-Screen: The figure is positioned off-screen (or as close as possible) based on the screen size. This makes it less obtrusive but still technically visible to the operating system.
- Modal Window: Setting the figure to be 'modal' helps keep it in focus, which is necessary for capturing key presses.
- Screen Size Consideration: The script calculates the screen size to position the figure. Depending on your screen resolution and configuration, you might need to adjust the “figPosition” values.