I have a WinForms application with many menus, each menu has an average of 30 menu items. In any given menu there can be multiple words that start with the same letter.
Currently I use a simple method of creating an alt key mapping to each item by prepending an ampersand to the begging of each menu item.
I need to be able to detect a duplicate key mapping (starting letter) and reassign it to another character; on that hasn’t been taken yet. The winning character would be the one closest to the begging of the word as possible.
MENU Example
- List item
- New Window
- Save Document
- Print Preview
A more ideal algorithm would be smart enough to look at the next word in the string, and have addition rules. If I could create a set of rules that emulates a menu such as this:

I understand that fire fox most likely assigns their mappings manually – but I am trying to be constructively lazy.
Since you have an average of 30 items, there’s always going to be accelerator letters that are used more than once. And you certainly don’t want an item’s letter changing over multiple runs (or worse, multiple menu uses within the same run) of your program.
Why not just keep it simple and require each menu item to have a static ‘accelerator letter’ property?