#840 – Access Keys Should Be Unique within A Window

An access key is a character that the user can press, in combination with the Alt key, in order to activate or give a control focus.  Because a user’s key press is associated with a particular control, you should ensure that each access key is unique within the parent window.

If you do happen to define the same access key for multiple controls within a window, pressing the access key will toggle the focus between the controls, rather than activating them.  In the example below, press Alt+T will toggle the focus back and forth between the two buttons.  If you then change the second access key to something different, pressing Alt+T will activate (press) the first button.

        <Button Content="_This" VerticalAlignment="Top"
                Padding="10,5" Margin="5"
                Click="DoThis_Click"/>
        <Button Content="_That" VerticalAlignment="Top"
                Padding="10,5" Margin="5"
                Click="DoThat_Click"/>
Advertisements