Syntax
c=getkeyboardcharpause([chrset])
Input Parameter
chrset : | | set of allowed character; default is 1:255 |
Output Parameter
c : | | uint8 of char pressed during pause command and rotate3d was on |
Examples
getkeyboardcharpause % returns the pressed key
Copyright 2020-2025 Tim C. Lueth. All rights reserved. The code is the property of Tim C. Lueth and may not be redistributed or modified without explicit written permission. This software may be used free of charge for academic research and teaching purposes only. Commercial use, redistribution, modification, or reverse engineering is strictly prohibited. Access to source code is restricted and granted only under specific agreements. For licensing inquiries or commercial use, please contact: Tim C. Lueth
Algorithm (Workflow)
This function, getkeyboardcharpause
, is designed to capture a character input from the keyboard when a MATLAB figure is open, particularly when the rotate3d
mode is active. The function is part of the SolidGeometry library and was introduced in version 5.0.
Input Parameters
- chrset: This is an optional parameter that specifies the set of allowed characters. If not provided, it defaults to the range 1:255, which includes all standard ASCII characters.
Output
- c: This is the output of the function, representing the ASCII value of the character pressed during the pause command. It is returned as a
uint8
type.
Algorithm Steps
- The function begins by calling
getfuncparams
to retrieve the chrset
parameter from the input arguments. If no input is provided, it defaults to the range 1:255.
- It initializes the variable
c
to 0.
- The function enters a
while
loop that continues until a character from the allowed set (chrset
) is detected.
- Inside the loop, the
shg
command is called to bring the current figure window to the front.
- The
pause
command is used to halt execution until a key is pressed.
- After a key press, the function retrieves the current character from the figure using
get(gcf, 'CurrentCharacter')
and converts it to a uint8
type.
- The loop checks if the character is within the allowed set. If not, it repeats the process.
- Once a valid character is detected, the loop exits, and the function returns the character's ASCII value.
This function is particularly useful in scenarios where the rotate3d
mode is active, as it allows for capturing keyboard input despite the usual blocking of callbacks.
Algorithm explaination created using ChatGPT on 2025-08-19 06:58. (Please note: No guarantee for the correctness of this explanation)
Last html export of this page out of FM database by TL: 2025-09-21