MATLAB Community

MATLAB, community & more

The history of keyboard shortcuts in MATLAB


I’d like to welcome guest blogger Christina Roberts from the MATLAB Editor team. Christina was the lead developer on the configurable keyboard shortcuts feature.

My last post gave an overview of how to use the new keyboard shortcut preference panel. This post is going to delve into the history of keyboard shortcuts in MATLAB, which will help make it clearer why we decided to change some of our default keyboard shortcut assignments.

The MATLAB desktop was developed over many years by a number of different developers. Although the developers attempted to follow platform standards for common actions, some MATLAB-specific actions were assigned different keyboard shortcuts in different desktop tools, depending on which developer created the tool. A good example of this, illustrated below in the legacy R2009a Windows Default Set, is the Open Selection action available across the desktop. In addition to the four different shortcuts that you can see below, there are a few tools with the action that have no shortcut at all.

Further complicating issues, the original keyboard shortcuts assigned to the Command Window were based on Emacs, regardless of platform. Other platform-specific shortcuts were also added to the Command Window, as long as they did not conflict with existing Emacs shortcuts; for example, Ctrl+O was added on Windows to perform Open, but Ctrl+A could not be assigned to the Command Window’s Select All action because Ctrl+A was the Emacs assignment for moving the cursor to the beginning of the line.

Before long, customers began asking for the ability to configure keyboard shortcuts in the Editor and Command Window, which were the primary desktop tools at the time. To help accommodate those requests, three default sets were developed for the Editor and the Command Window, and users could choose between those sets independently (with the caveat that the Macintosh set was only available on the Macintosh platform). To maintain backwards compatibility, the defaults remained as they had been, even though they were inconsistent between the Editor and the Command Window—the Command Window stayed with the Emacs-based shortcuts on all platforms, but the keyboard shortcut set selected for the Editor by default varied by platform. This was very confusing for new MATLAB users, who expected a more consistent user experience.

As MATLAB continued to evolve, additional tools were added to the desktop, and their keyboard shortcuts were hard-coded to the values that the individual developers felt made sense. So although users appreciated having some choice of keyboard shortcuts in the Editor and Command Window, we continued to receive many requests for customization of individual keyboard shortcuts across the whole desktop. This was particularly needed for customers using certain non-English keyboards, which simply could not trigger some of our default shortcuts.

Presented with the challenge of creating a new keyboard shortcut infrastructure, I had several requirements. I wanted to provide a way to unify keyboard shortcuts across desktop tools so that, by default, the same action had the same shortcut, regardless of where it was triggered. However, I knew that making such a change would introduce backwards incompatibilities and possibly annoy existing MATLAB users, so I wanted to ensure that flexibility existed for customers to achieve exactly the same hybrid configurations that we previously supported. At the same time, this flexibility could not be burdensome to users who desired to quickly change a keyboard shortcut across the desktop, without dealing with individual tools.

So now let’s take a look at the solution that I developed, using the Ctrl+A example discussed above. First, compare the Ctrl+A assignments in the new Windows Default Set to the assignments in the legacy R2009a set.

New Windows Default Set as of R2009b

Old Windows Default Set as of R2009a

In R2009a on Windows, Ctrl+A was not assigned to Select All in the Command Window, and instead had the Emacs-based assignment of Cursor Begin Line. Now, let’s assume that you are an existing MATLAB user and you have Ctrl+A committed in your muscle memory to going to the beginning of the line. You have 2 options—you can revert back to the legacy R2009a Windows Default Set, or you can modify the Select All and Cursor Begin Line assignments in the new default set.

Modifying the new default set is a far better long term solution if there are a relatively small number of keyboard shortcuts that are bothering you. If you stick with our new default sets, as new actions and tools are added to the desktop, you will automatically obtain their keyboard shortcuts—this is because we only store the customizations (differences) that you have made from our shipping defaults. In contrast, the legacy sets are complete listings of exactly what we had in release R2009a, and they will not evolve with new features.

So let’s change the assignments related to Ctrl+A in the new Windows Default Set. To do this, first click on Select All and then un-assign the Command Window from the list of tools with the Ctrl+A shortcut.

Then select Cursor Begin Line, press the button, and add a new shortcut of Ctrl+A to the Command Window only.

If you now search for Ctrl+A in the table of actions, and you will see that the assignments match the ones in R2009a.

That is a quick summary of how the new customizable keyboard shortcuts were developed. I hope that you find this feature useful, and I’d love to hear your feedback!

-by Christina Roberts, The MathWorks

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.