YouTip LogoYouTip

Prop Webcontrol Standard Accesskey

## ASP.NET WebControl AccessKey Property The `AccessKey` property is a standard property shared across ASP.NET Web Controls. It allows developers to define a keyboard shortcut (hotkey) that users can press to quickly navigate to or set focus on a specific control. --- ## Definition and Usage The `AccessKey` property sets or returns the keyboard character used to access a Web Control. By defining an access key, you improve the accessibility and usability of your web application, allowing users to navigate form elements, buttons, and inputs using their keyboard instead of a mouse. ### Browser Behavior To trigger the access key shortcut, users typically press a modifier key combination along with the specified `AccessKey` character. The exact combination depends on the user's operating system and browser: * **Windows / Linux:** `Alt` + `` (or `Alt` + `Shift` + `` in some browsers like Firefox) * **macOS:** `Ctrl` + `Alt` + `` (or `Control` + `Option` + `` in Safari/Chrome) --- ## Syntax ```syntax ``` ### Property Values | Property | Description | | :--- | :--- | | **AccessKey** | A single character (letter or digit) that acts as the keyboard shortcut to access the control. | --- ## Code Example The following example demonstrates how to assign the access key `"y"` to an ASP.NET CheckBox control. ```asp
``` --- ## Important Considerations 1. **Single Character Limitation:** The `AccessKey` value must be a single string character (e.g., `"a"`, `"1"`). If you provide a string with multiple characters, only the first character will be used as the access key. 2. **Browser Conflicts:** Be cautious when choosing access keys. Some letters are already reserved by web browsers or screen readers for system navigation (e.g., `Alt + F` for the File menu). 3. **Visual Cues:** The `AccessKey` property does not automatically underline or highlight the shortcut character in the control's text label. It is best practice to visually indicate the shortcut to the user (for example, by writing "Accept Terms (Alt + Y)" or using CSS to underline the shortcut letter).
← Prop Webcontrol Standard BackcAtt String Isdecimal β†’