MATLAB 2025: Why can't I close a figure using Mac keyboard shortcuts?

I just downloaded MATLAB 2025a and all is working well so far except a strange quirk: There is no easy way to close a figure window using standard Mac keyboard shortcuts.
In previous versions, I can close a figure window by pressing the standard Cmd+w. This keyboard shortcut is used across Mac to close windows, browser tabs, documents, etc. Its a very generic keystroke and not in the list of MATLAB-specific keyboard shortcuts.
It's very bizarre because literally all other generic Mac keyboard shortcuts still work fine in MATLAB 2025, even when applied to figure windows. For example, I can minimize the figure window using Cmd+m. I can also toggle between figure windows using Cmd+`. So other Mac keyboard shortcuts apply to figures fine.
Adding to the mystery, I can still use the exact same Cmd+w keyboard shortcut to close an m file that is open in the editor. So the Cmd+w shortcut is recognized within MATLAB 2025. But does not work to close a figure.
Maybe its just me being nitpicky, but its really annoying because I use a lot of keyboard shortcuts in my work. Currently the only alternative is to reach all the way to my mouse and move the mouse to the x and click to close the figure, or I have to type "close" in the command window. Each of these takes at least 10x longer than hitting Cmd+w to quickly close a single figure.
Anyone else experiecing this? Any fix?

5 Comments

Hi @Darcy,
I am also facing the same issue with R2025a, and not able to find any fix till now.
Many Mac shortcuts stopped working in the new desktop beta (release 2023b and later?). Most of them seemed to have been restored in release 2025a, but not this one. I also would like that functionally again.
Strange observation: Control-W on the Windows version of release 2025a closes figures but not uifigures. Alt-F4 will close either.
Why did the MATLAB coders eliminate basic functionality from these versions? Using a pointing device of any kind always takes more work/time than using a keyboard shortcut. Presumably hard-core coders understand how little I want to use a mouse when I am coding. Fix this bug before it becomes a feature, please.
Still same problem for me on 2025b. Annoying.
Same probleme here. Annoying. I use this shortcut very often. Does anybody know a workaround? cmd+w for closing windows is standard, AFAIK. Thanks!

Sign in to comment.

 Accepted Answer

Type this:
set(groot, 'DefaultFigureKeyPressFcn', @(src,event) strcmp(event.Key,'w') && any(strcmp(event.Modifier,'command')) && close(src));
It worked for me (MacBook pro 2023 M2; macOS Tahoe 26).
The bad news: when Matlab is restarted, the instruction must be loaded again, so I write it at the begginig of the script, with clear all and clc commands. Moreover, the shortcut section in Matlab Preferences cannot be edited (no new shorcuts can be added), so the problem is a bit more anoying. Lets wait for any updated version...

3 Comments

Great! This works for me, too (macOS Tahoe 26.2)! Thank you very much!!
Good news: add this line to your startup.m file and then it also works after a matlab restart (see startup).

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2025a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!