Skip to content

Add keyboard shortcuts to menus#14490

Open
rlament wants to merge 8 commits into
vassalengine:release-3.7from
rlament:14203-shortcut-key
Open

Add keyboard shortcuts to menus#14490
rlament wants to merge 8 commits into
vassalengine:release-3.7from
rlament:14203-shortcut-key

Conversation

@rlament

@rlament rlament commented Feb 11, 2026

Copy link
Copy Markdown
Contributor

Add keyboard shortcuts to the Module Manager, Editor and the Player windows. The shortcut keys are language specific and are defined in the language resource files. The English and all European languages have shortcut keys assigned. This was an interesting exercise in increasing my gaming vocabulary.

I welcome native language speakers to chime in on the language specific shortcut key assignments. Almost undoubtedly there are predefined shortcut keys for the typical operating system commands that I am not aware of. My attempt here is to make shortcut keys unique per sub-menu.

In the Editor, hotkeys are not assigned since most of the editor commands have accelerator keys.

Also in the editor, 'File|Save As' had been given the control-A accelerator key. This is the 'Select All' command which is intercepted by the edit controls. Only if the menu has focus does the control-A accelerator key work as a Save-As. This somewhat defeats the purpose of having an accelerator key. Changing Save-As to shift-control-S makes Save-As available just like control-S for File|Save.

Toolbar buttons have precedence over menus. For example if a module uses Alt-F for an Action Button, then the File menu for the English language (and some others) will not open. F10 would if it is not also reassigned. Shortcut keys can be useful but they can be masked by modules.

Change SaveAs accelerator key from ctrl-A to ctrl-shift-S
ctrl-A is the 'select all' editor command and is hooked by the
editor before the File menu sees the ctrl-A.
Shortcut keys are language specific and defined in the resource files.
Add the shortcut keys to the default resource files.
@cholmcc

cholmcc commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

Nice initiative - short cuts for menu items have been sorely missing. However, I'm a little worried that defining menu short-cuts like Ctrl-S, Ctrl-A, Ctrl-F, and so on, will conflict with module-specific short-cuts. In other words, a module could for example have defined Ctrl-Q to fire a Global Hotkey or even a Key command. Will the key combination be sent to the menu or to the module? And if it depends, under what circumstances will the key combination end up one or the other place?

Yours,
Christian

@rlament

rlament commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

defining menu short-cuts like Ctrl-S, Ctrl-A, Ctrl-F, and so on ...
Will the key combination be sent to the menu or to the module?

We have to frame this discussion solely around the Player window. That window specifically has the potential conflicts with modules. The Player window has three top level menu items, in English File, Tools, and Help. That's Alt-F, Alt-T and Alt-H respectively. Any of these move focus to the menu. BTW, F10 is another key that sends focus to the menu. Once there the user can press the underscored letter corresponding to desired command. As an example, for New Game it's Alt-F -> N. Or the user can traverse the menu with arrow keys and press the Enter key. The potential conflict is only with the three Alt codes.

It does get interesting because the three Alt codes change from language to language. The German word for Tools is Werkzeuge, so Alt-W would make a lot of sense. But Alt-W is the Begin log file keycode unless a module designer explicitly changes it. This means that certain letters are off limits and annoyed German users have to use some less obvious letter. Alt-S is the server control window putting it off limits too. Both of these are configurable in the Global Options, but it probably is best to avoid the default settings.

Buttons on the toolbar take precedence over the menu. You get solely the toolbar action and not both (i.e. not the menu). If a counter(s) has focus, it takes precedence over the toolbar buttons.

In regards to control codes, the Module Editor has always had these defined. There is nothing new here for control codes. I just pointed out the conflict with Save As and the resolution.

@cholmcc

cholmcc commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

defining menu short-cuts like Ctrl-S, Ctrl-A, Ctrl-F, and so on ...
Will the key combination be sent to the menu or to the module?

We have to frame this discussion solely around the Player window. That window specifically has the potential conflicts with modules. The Player window has three top level menu items, in English File, Tools, and Help. That's Alt-F, Alt-T and Alt-H respectively. Any of these move focus to the menu. BTW, F10 is another key that sends focus to the menu. Once there the user can press the underscored letter corresponding to desired command. As an example, for New Game it's Alt-F -> N. Or the user can traverse the menu with arrow keys and press the Enter key. The potential conflict is only with the three Alt codes.

OK, thanks for clarifying. That certainly calms my nerves a bit 😃

On the other hand, it means to reach, say - Save Game one would need the key sequence Alt-FS, right? Compared to most other applications, it is a bit convoluted compared to, say, Ctrl-S. However, it is better than nothing, and probably the most backward-compatible way.

It does get interesting because the three Alt codes change from language to language. The German word for Tools is Werkzeuge, so Alt-W would make a lot of sense. But Alt-W is the Begin log file keycode unless a module designer explicitly changes it. This means that certain letters are off limits and annoyed German users have to use some less obvious letter. Alt-S is the server control window putting it off limits too. Both of these are configurable in the Global Options, but it probably is best to avoid the default settings.

As noted elsewhere, I find translating the key a bit odd. At least for Danish. Most Danes are quite comfortable with using S for Save - as opposed to G for Gem - in fact, S is the more usual short cut and G would be wholly unexpected. I would advice against translating these key codes unless there's a strong precedence for doing so in a particular language.

Yours,
Christian

@rlament

rlament commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

using S for Save - as opposed to G for Gem - in fact, S is the more usual short cut and G would be wholly unexpected

That's interesting. Shows how little I know. The File menu in the Player Module is the longest menu and often with repeat wording. I put the S on Afslut logfil since the A was already taken by Afslut. Nothing saying one can't reuse the same letter, maybe for save and save as, but not dissimilar actions like save log file and quit.

If the chosen shortcut key (letter) is not in the word there is no visible cue to the end user. S can work for Gem since it's followed with Spil as in Gem Spil.

No easy choices here. Tools menu isn't much better with three Load commands. You are welcome to edit the properties file to your liking.

@cholmcc

cholmcc commented Feb 12, 2026

Copy link
Copy Markdown
Collaborator

No easy choices here. Tools menu isn't much better with three Load commands. You are welcome to edit the properties file to your liking.

My issue is not so much with the choice of letter - clearly there will be some overlaps to sort out. My issue is using translations of the key. That, I believe is wholly unexpected by most users - even if their language of choice isn't English. For example, a Danish user would expect the key Q to quit the application - not A.

To be more explicit

Module mananger

File menu Key Danish
Open Module ... O Åben modul ...
Edit Module ... E Rediger modul ...
New Module ... N Nyt modul ...
Preferences P Præferencer
Quit Q Afslut
Tools menu Key Danish
Server status S Server status
Convert Module ... C Konverter modul ...
Clear Tile Cache X Ryd flise lager
Help menu Key Danish
Help H Hjælp
Take the tour T Tag rundturen
Vassal's users guide V Vassel brugermanual
Check for updates ... U Tjek for opdateringer ...
Show Error Log L Vis fejl rapporter
About Vassal A Om Vassal

Player

File menu key Danish
New game ... N Nyt spil ...
Load Game or Log ... O Åben spil eller optagelse ...
Open recent ... R Åben seneste ...
Save Game ... S Gem spil ...
Save Game as ... A Gem spil som ...
Close Game X Afslut spil
Start Log ... L Start optagelse ...
End Log E Afslut optagelse
Preferences P Præferencer
Scenario Options C Scenarie valg
Quit Q Afslut
Tools menu Key Danish
Load Log & Fast-forward F Åben optagelse og spol fremad
Load Log, Fast-forward, and append A Åben optagelse, spol fremad, og tilføj
Load continuation C Åben forsættelse
Refresh Counters R Opdater brikker
Show Debug Window D Vis afluser vindue

In short, do not pay any attention to the translated menu entry text when assigning a letter to a menu entry, but use the same letter irrespective of the choice of language by the user. That, I believe, is what most users will expect.

Yours,
Christian

@riverwanderer

Copy link
Copy Markdown
Collaborator

On MacOS I see nothing different. Is the change restricted to Windows ?

@rlament

rlament commented Feb 14, 2026

Copy link
Copy Markdown
Contributor Author

On MacOS I see nothing different. Is the change restricted to Windows ?

No, should work with Mac too. On the Module Manager, the first character of every File menu entry should be underlined. On Windows it depends on how the menu is opened. Mac might be the same. Use the keyboard to open the menu, Alt-F or whatever is the equivalent for Alt on the Mac. When clicking on 'File' with the mouse the underscores are not shown. Does Alt-F Q close the Module Manager? If so then it is working.

On Linux the underscores are present regardless. The appearance on each O/S may be affected by the look and feel? I'm not sure.

@riverwanderer

riverwanderer commented Feb 14, 2026

Copy link
Copy Markdown
Collaborator

No, should work with Mac too.

I tried Alt-F (Option-F on Mac) etc and it does nothing. I have a feeling that MacOS does not deal with shortcuts in this way. My "research" seems to confirm that.

@rlament

rlament commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

@riverwanderer Sorry, novice mistake assuming that Java UI controls work more or less the same across operating systems. Got on a Mac briefly and noticed that it somewhat already supports shortcut keys. From Apple support:

Control-F2 or Fn-Control-F2: Move focus to the menu bar. You can then use the arrow keys to navigate the menu, press Return to open a selected menu or choose a selected menu item, or type the menu item's name to jump to that item in the selected menu.

The point to note is "type the menu item's name to jump to that item". In effect the first letter of the menu item is the shortcut key once the menu has focus.

The Control-F2 equivalent on Windows is F10.

@cholmcc The latest commit modifies the Danish menu to follow your suggested shortcut keys. For English, I did not change any of the existing shortcuts. Redefining the few pre-existing shortcuts would be unkind to end users.

Below is a list of differences between English and Danish shortcut keys. All the others are the same for both languages. The three criteria for the English shortcuts are:

  1. Pre-existing shortcuts remain unchanged.
  2. Must be a letter within any word, preferably the first letter.
  3. Prefer a unique letter for each menu item avoiding duplicates.
English menu English shortcut Danish shortcut
Begin Logfile B L
Load Game or Log L O
Close Game C X
Clear Tile Cache T X
Scenario Options O C

use the same letter irrespective of the choice of language

The menu items identify the shortcut with an underscore. This works fine for English since the shortcut letter always matches some letter in one of the words. This presents a visual cue for the end user. A translated menu item may not have the equivalent letter, thus with nothing underlined it falsely signifies an unassigned shortcut (see Luk spil in the figure). I can see being consistent with common operating system commands like File->New, but not so much with Vassal specific commands.

I've also added the accelerator keys to the menu as shown below in the red box. Unsure if these are visible on the Mac. These are the keycodes as defined in General Options.

File_menu

@cholmcc

cholmcc commented Feb 17, 2026

Copy link
Copy Markdown
Collaborator

Below I attach some screenshot from

  • Linux - system Look'n'Feel (GTK) and Metal Look'n'Feel
  • MacOS - system Look'n'Feel
  • Windows - Metal Look'n'Feel

Linux

System Look'n'Feel

MenuHotkeyLinuxModuleManager MenuHotkeyLinuxPlayer

The mnemonics keys are not visible. The keys still work as expected, but the hotkeys are not shown

Metal Look'n'Feel

MenuHotkeyLinuxModuleManagerMetalLnF

The mnemonic keys are shown and work as expected

MacOS - System Look'n'Feel

MenuHotkeyMacOSModuleManager MenuHotkeyMacOSPlayer

Mnemonic keys are not shown, nor do they work as expected. Instead, the regular MacOS menu navigation works (type S A to navigate to Save Game ..., Enter to select)

Windows - Metal Look'n'Feel

MenuHotkeyWindowsModuleManager MenuHotkeyWindowsPlayer

Mnemonic keys are shown and work as expected.

The point is that what determines if the keys are shown is likely the Look'n'Feel - not the OS. For Linux and MacOS, the system Look'n'Feel will not show the mnemonic keys, and what is worse, they will still work on Linux with the system Look'n'Feel - without alerting the user to those keys.

With a simple Look'n'Feel like Metal - and probably other built-in Look'n'Feels - the Mnemonics are shown and work.

What wasn't clear to me from the outset, is how the mnemonic keys would be shown and function. I was under the impression that a mnemonic key of - say - S would be shown as an S after the menu entry, right-adjusted to the right edge of the menu - sort of like Alt-W for Begin logfile ... above. In that case, it does not make sense to translate the mnemonic keys.

Instead, the mnemonic key will be shown as an underline under the relevant letter in the menu entry - for that, it makes sense to translate the mnemonic keys according to the chosen language.

However, those kinds of hotkeys are very rare these days. While they were prevalent some 20 years ago, you don't see them often these days - except in legacy Windows applications. Instead, most modern UIs use some sort of key combinations like Ctrl-O and so on.

I would question the usability of these kinds of mnemonic keys. I think most users will not be very familiar nor inclined to use such mnemonic keys. Also, since the keys will "quietly" (no indication of a mnemonic key in the UI) work, I think it can be quite confusing to users.

Anyway, my 2¢

Yours,
Christian

@rlament

rlament commented Feb 19, 2026

Copy link
Copy Markdown
Contributor Author

the system Look'n'Feel will not show the mnemonic keys, and what is worse, they will still work on Linux with the system Look'n'Feel - without alerting the user to those keys

How did the menu receive the focus? Did you press F10 or press and hold the Alt key? I am seeing that the underline is present when the menu receives focus through a keyboard command. Using the mouse, the underline is not shown but the shortcut keys still work as the menu has the focus. Pressing the Alt key after clicking on the menu with the mouse also turns on the underline. The dropdown list is not updated until refreshed by moving to another menu item and back again. The underline is not always shown being dependent on how the user navigates the menu (and the Look'n'Feel).

@cholmcc

cholmcc commented Feb 19, 2026

Copy link
Copy Markdown
Collaborator

How did the menu receive the focus? ... Pressing the Alt key after clicking on the menu with the mouse also turns on the underline.

Ah, I see - see screenshot below

MenuHotkeyLinuxModuleManagerAltDown

Edit: The screenshot doesn't show it - hard to capture the right screenshot with Wayland - one of the few regressions from X11.

Indeed, holding down Alt makes the underlines appear.

... but the shortcut keys still work as the menu has the focus ...

Since the mnemonic keys work even if the menu was invoked by Mouse1, this makes it perhaps worse. Clearly, the expectation is, that if there's a mnemonic key, it should be evident when it is enabled, and when it is not shown, the mnemonic keys should be disabled:

  • Underline shown if and only if mnemonic key enabled

It's not a problem of Vassal or the current PR - rather, it seems to be an issue in the GTK Look'n'Feel, or perhaps the Java Swing components.

Yours,
Christian

…nguages

Prefer not to change existing shortcuts that users may be accustomed to.
Where possible try to limit top level player menu to Alt-F, Alt-T and Alt-H
in order to minimize masking by toolbar buttons.
@rlament

rlament commented Feb 22, 2026

Copy link
Copy Markdown
Contributor Author

My understanding of the dynamic nature of the underscore is basically a compromise between asethetics and accessibility. Mouse users don't care to see them. They do assist keyboard users with speedier navigation than with arrow keys alone. The behaviour is not limited to Swing or any particular look and feel, VSCode on Windows works the same way.

Since MacOS completely disregards the shortcut keys instead using the first letters of the menu item, for greater cross-platform commonality the best shortcut key would be the first letter of each menu item. But, any pre-existing shortcuts should remain unchanged as much as possible. I have compared the latest release with this PR and reverted some of my earlier changes.

@cholmcc Are you considering any modifications to the Danish shortcuts? I can update shortcuts as you see fit.

@rlament

rlament commented Feb 24, 2026

Copy link
Copy Markdown
Contributor Author

Taking the shortcut key table a step further, this is the output of a PowerShell script of all shortcut keys defined by this PR within the resource files by language. A blank entry indicates no override for that language deferring back to the English default.

An asterisk indicates a hidden shortcut key. The shortcut key is active but not readily apparent to the user since the menu text does not contain an instance of that letter. Ideally there should not be any asterisks in this table. Looking for some assistance in nailing down reasonable and intuitive shortcuts.

Updated: 2026/02/28 (update 2)

reference text en da de es fr it ja nl pl zh
AboutScreen.about_vassal About VASSAL A O I W I
BasicLogger.begin_logfile Begin Logfile... B O T I D I * R B
BasicLogger.end_logfile End Logfile E L C F T F * Z E
Chat.server_status Server Status S * *
Debug.show_debug_window Show Debug Window D V
GameRefresher.refresh_counters Refresh Counters R O C A O *
GameState.close_game Close Game C F E E Q C * T Z C*
GameState.load_and_append Load Log, Fast Forward & Append... L T X L
GameState.load_and_fast_forward Load Log & Fast Forward... F Å R W
GameState.load_continuation Load Continuation... C F O C * V K
GameState.load_game Load Game... L Å C C L * W L*
GameState.new_game New Game N N N N N * N N*
GameState.open_recent Open Recent... R S O
GameState.save_game Save Game S G G S S * A S*
GameState.save_game_as Save Game As... A E U A A A J A
General.edit Edit E R B E E M * E E E*
General.file File F F D F* F F * F* P F
General.help Help H H H* A A * H O H*
General.quit Quit Q A B S B * V Y *
General.tools Tools T T * T T T * T* N T*
Main.edit_module Edit Module... E R M M * O *
Main.import_module Convert Module... C K M C I * K
Main.new_module New Module N * *
Main.play_module Open Module... O Å A J G * S *
ModuleManager.clear_tilecache Clear Tile Cache T R L V W *
Prefs.edit_preferences Preferences P V * V *
ScenarioOptions.menu_text Scenario Options O V

@cholmcc

cholmcc commented Feb 24, 2026

Copy link
Copy Markdown
Collaborator

@cholmcc Are you considering any modifications to the Danish shortcuts? I can update shortcuts as you see fit.

Note, my initial objection was to hotkey short-cuts - e.g., a key like Ctrl-A for Quit. However, what you are defining are mnemonic keys - e.g., Alt-F+A for Quit. For mnemonic keys, it makes sense to translate them according to the menu entry. E.g.,

Module mananger

File menu Key Danish Key
Open Module ... O Åben modul ... Å
Edit Module ... E Rediger modul ... R
New Module ... N Nyt modul ... N
Preferences P Præferencer P
Quit Q Afslut A
Tools menu Key Danish Key
Server status S Server status S
Convert Module ... C Konverter modul ... K
Clear Tile Cache X Ryd flise lager R
Help menu Key Danish Key
Help H Hjælp H
Take the tour T Tag rundturen T
Vassal's users guide V Vassel brugermanual V
Check for updates ... U Tjek for opdateringer ... O
Show Error Log L Vis fejl rapporter F
About Vassal A Om Vassal M

Player

File menu key Danish Key
New game ... N Nyt spil ... N
Load Game or Log ... O Åben spil eller optagelse ... Å
Open recent ... R Åben seneste ... S
Save Game ... S Gem spil ... G
Save Game as ... A Gem spil som ... E
Close Game X Afslut spil F
Start Log ... L Start optagelse ... O
End Log E Afslut optagelse L
Preferences P Præferencer P
Scenario Options C Scenarie valg V
Quit Q Afslut A
Tools menu Key Danish Key
Load Log & Fast-forward F Åben optagelse og spol fremad Å
Load Log, Fast-forward, and append A Åben optagelse, spol fremad, og tilføj T
Load continuation C Åben forsættelse F
Refresh Counters R Opdater brikker O
Show Debug Window D Vis afluser vindue V

However, I still find it problematic to add these mnemonic keys when

  • they are not shown by default with certain Java Look'n'Feels, but the still work - users may get confused that pressing Alt-F followed by P opens the preference dialog when there's no indication in the UI of such a mnemonic key
  • they do not work on certain platforms - e.g., MacOS - at all - in fact, Alt-F doesn't even show the File menu (Ctrl-F2 does).

Yours,
Christian

@rlament

rlament commented Feb 26, 2026

Copy link
Copy Markdown
Contributor Author

Updated the Danish translation file. These are the outstanding issues as far as I can tell.

  1. What is the preferred keycode for the top level Værktøjer menu? Alt-T to match the English Tools, or Alt-V?
  2. Typo in Åben forsættelse? Should be fortsættelse, correct?
  3. For the help menu, there is little value in adding mneumonic keys. I only added one for "About". Should Om VASSAL stay as M or is O better since there are no other conflicts?
  4. I left Scenarie indstillinger unchanged and used the letter I. Too many other messages use the word indstillinger to change the menu text. Better to be consistent with the terminology.
  5. I took a stab at updating GameState.old_continuation_warning since it refers to altered menu items. I think the message is outdated still referring to the old location of Load Continuation under the files menu. Pointing this out in case you have a chance to review it. Although I'm not trying to turn this PR into a translation exercise.

The Vassal resource files use the term shortcut, so for source code consistency I kept with the same wording.

I will edit my earlier post and update the table.

@cholmcc

cholmcc commented Feb 26, 2026

Copy link
Copy Markdown
Collaborator

Updated the Danish translation file. These are the outstanding issues as far as I can tell.

  1. What is the preferred keycode for the top level Værktøjer menu? Alt-T to match the English Tools, or Alt-V?

Hot-keys should not be translated - that would be totally unexpected to most users - not just Danish users. For example, Tools in German is Werkzeuge, but I sincerely believe German users would be surprised if the hot-key is Alt-W.

Just dawned on my that I hadn't translated the menu headings:

English Danish
File Fil
Tools Værktøjer
Help Hjælp
  1. Typo in Åben forsættelse? Should be fortsættelse, correct?

Right. My bad.

  1. For the help menu, there is little value in adding mneumonic keys. I only added one for "About". Should Om VASSAL stay as M or is O better since there are no other conflicts?

Take the first letter if there's no conflict.

  1. I left Scenarie indstillinger unchanged and used the letter I. Too many other messages use the word indstillinger to change the menu text. Better to be consistent with the terminology.

The proper translation of options is valg - not indstillinger. Indstillinger is more like Settings or perhaps Preferences.

  1. I took a stab at updating GameState.old_continuation_warning since it refers to altered menu items. I think the message is outdated still referring to the old location of Load Continuation under the files menu. Pointing this out in case you have a chance to review it. Although I'm not trying to turn this PR into a translation exercise.

You have:

GameState.old_continuation_warning=Indlæsning af vlogs direkte (med "Åben spil eller optagelse") er normalt den sikreste måde at genafspille dem på. Legacy Continuation-loading skaber ofte forvirring og er meget følsomt over for den mindste spillerfejl eller utilsigtet proceduremæssig fejl. Kun meget specielle tilfælde kræver legacy indlæsning. Åben fortsættelse findes nu i menuen Værktøjer.

translated from

GameState.old_continuation_warning=Loading vlogs directly (with "Load Game or Log") is usually the safest way to replay them.\n\nLegacy continuation loading often creates confusion and is very sensitive to the slightest player mistake or accidental procedural misstep. Only very special use cases require legacy loading.

I suggest

GameState.old_continuation_warning=Den bedste måde at åbne en optagelse, er for det meste "Åben spil eller optagelse ...".  Den ældre "Åben fortsættelse ..." metode medfører ofte forvirring, og er følsom overfor selv små spiller- eller procedurefejl.  Den ældre måde er kun nødvendig i ganske særlige tilfælde.

(Auto-translators often f**k up sentence structure, which is somewhat different between Danish and English - despite English being closely related to Danish and Norse - Denmark did, after all, rule England, and William the Conqueror's claim to the English thrown came from his Danish ancestry - albeit a somewhat strained linage 😄 )

The Vassal resource files use the term shortcut, so for source code consistency I kept with the same wording.

OK.

I will edit my earlier post and update the table.

OK.

Yours,
Christian

Change Load Log, Fast Forward & Append shortcut to "L"
Ensure all shortcuts are uppercase (for consistency only).
Rephrase Danish language load continuation informational message.
@rlament

rlament commented Mar 1, 2026

Copy link
Copy Markdown
Contributor Author

I've made all the changes including updating Scenarie valg. Replaced the load continuation informational message with the new text. I leave it to someone more qualified to resolve any inconsistencies in messaging between valg and indstillinger, and Åben and Indlæs.

Changed the default shortcut for Load Log, Fast Forward & Append to "L" from "A". Using "A", the underscore is hard to see as the first occurrence receives the underscore which happens to be the lowercase "a" in "Load". In contrast, the "L" in load has greater visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants