Hi Antony
According to my comprehension, you are trying to add 'F5' key as an accelerator to a menu item but getting an error on doing so.
In MATLAB App Designer, when you try to set an accelerator key for a menu item, the accelerator property typically expects a single character (such as 'N' for a "New" command) or an empty character array.
This is why you are seeing the error message when you try to set 'F5' as the accelerator, as 'F5' is more than one character and is not recognized as a valid input for the property.
However, there is a way to work around this limitation by using the 'KeyPressFcn' callback of the figure (the main UI window) to detect when the F5 key is pressed.
As a workaround try out the following:
app.UIFigure.KeyPressFcn = @app.figureKeyPress;
function figureKeyPress(app, event)
if strcmp(event.Key, 'f5')
function menuItemCallback(app)
- We set the 'KeyPressFcn' property of the figure to a custom callback function that you will define.
- In the callback function, check if the pressed key is 'f5'.
- If 'f5' is detected, execute the same code you would have tied to the menu item's accelerator.
I hope the above workaround resolves your query.