---
description: >-
  This feature ensures that the control is accessible and can be navigated and
  manipulated using keyboard shortcuts, making it user-friendly for a wide range
  of users.
---

# Accessibility & Keyboard Navigation

## Overview

The Accessibility & Keyboard Navigation feature of the SiticoneSplitContainer control is designed to improve usability for all users, including those who rely on assistive technologies. It provides properties such as `EnableKeyboardNavigation`, `EnableHotkeys`, and customizable key combinations (e.g., `SplitterMoveLeftKey`, `SplitterMoveRightKey`, `swapPanelsHotkey`, and `toggleOrientationHotkey`) that enable comprehensive keyboard control over the splitter. In addition, built-in accessibility properties ensure that the control is properly recognized by screen readers and other assistive devices.

***

### Key Points

| Aspect                    | Description                                                                                                                                                                                  |
| ------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Keyboard Navigation       | Use `EnableKeyboardNavigation` to allow users to navigate and adjust the splitter using keyboard arrow keys or custom key combinations.                                                      |
| Hotkey Support            | The control supports predefined hotkeys via properties like `EnableHotkeys`, `resetPositionHotkey`, `toggleLockHotkey`, `swapPanelsHotkey`, and `toggleOrientationHotkey` for quick actions. |
| Accessibility Attributes  | Built-in accessibility settings, including accessible names, roles, and descriptions, ensure that the control is usable with assistive technologies.                                         |
| Customizable Key Bindings | Developers can define custom key combinations to tailor the navigation experience to the needs of the application or target audience.                                                        |

***

### Best Practices

| Recommendation                       | Details                                                                                                                                                        |
| ------------------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Enable Keyboard Navigation Early     | Set `EnableKeyboardNavigation` to true during initialization to ensure that the control is accessible from the start.                                          |
| Customize Key Bindings Appropriately | Define key combinations that are intuitive and avoid conflicts with system or application-level shortcuts.                                                     |
| Test with Assistive Technologies     | Validate the accessibility features using screen readers and other assistive devices to ensure that names, roles, and descriptions are correctly communicated. |
| Provide Visual Feedback              | Combine keyboard navigation with visual cues (e.g., highlighting) to assist users in understanding current focus and control state.                            |

***

### Common Pitfalls

| Pitfall                         | Explanation                                                                                                                    | Mitigation Strategy                                                                                                     |
| ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------- |
| Ignoring Accessibility Settings | Overlooking the setup of accessible names and roles can lead to a poor experience for users relying on assistive technologies. | Always verify that the control's accessibility properties (e.g., AccessibleRole, AccessibleName) are set appropriately. |
| Conflicting Hotkeys             | Using key combinations that conflict with common system shortcuts or other application features can cause unexpected behavior. | Choose unique key combinations and test thoroughly to avoid conflicts.                                                  |
| Inconsistent Keyboard Behavior  | Inadequate implementation of keyboard events may result in erratic behavior, such as missed key presses or delayed response.   | Standardize key event handling and test across different operating systems and keyboard layouts.                        |

***

### Usage Scenarios

| Scenario                          | Description                                                                                                                  | Example Use Case                                                                                               |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
| Resizing Panels with the Keyboard | Users can adjust the splitter position using arrow keys or predefined hotkeys for finer control over panel sizes.            | A settings panel where users can resize panels by pressing the left/right arrow keys.                          |
| Swapping Panels via Hotkeys       | Use custom hotkeys to swap the panels quickly without resorting to mouse interactions.                                       | An application where rapid reordering of content panels is needed, triggered by a specific hotkey combination. |
| Toggling Orientation              | Allow users to change the control’s orientation (horizontal/vertical) with a simple key press.                               | A dashboard where users can toggle between different layout modes using a dedicated hotkey.                    |
| Enhancing Accessibility           | Ensure that users with disabilities can navigate the control effectively using keyboard shortcuts and screen reader support. | Integrating the control into an enterprise application with a strong emphasis on accessibility compliance.     |

***

### Code Examples

#### 1. Enabling Keyboard Navigation

The following example demonstrates how to enable keyboard navigation and customize key bindings for the control:

```csharp
public class KeyboardNavigationForm : Form
{
    private SiticoneSplitContainer splitContainer;

    public KeyboardNavigationForm()
    {
        InitializeComponent();
        splitContainer = new SiticoneSplitContainer
        {
            Dock = DockStyle.Fill,
            // Enable keyboard navigation and hotkeys
            EnableKeyboardNavigation = true,
            EnableHotkeys = true,
            // Customize key bindings for moving the splitter
            SplitterMoveLeftKey = Keys.Left,
            SplitterMoveRightKey = Keys.Right,
            // Define additional hotkeys for swapping panels and toggling orientation
            swapPanelsHotkey = Keys.Control | Keys.Alt | Keys.S,
            toggleOrientationHotkey = Keys.Control | Keys.Alt | Keys.O
        };

        // Optionally subscribe to keyboard-based events for additional feedback
        splitContainer.SplitterMovedViaKeyboard += (s, e) =>
        {
            Console.WriteLine($"Splitter moved via keyboard to position: {e.NewSplitterDistance}");
        };

        this.Controls.Add(splitContainer);
    }
}
```

#### 2. Handling Custom Hotkeys

This example shows how to implement custom event handling for hotkeys, such as resetting the splitter position or locking it:

```csharp
public class HotkeyHandlingForm : Form
{
    private SiticoneSplitContainer splitContainer;
    private Label statusLabel;

    public HotkeyHandlingForm()
    {
        InitializeComponent();
        splitContainer = new SiticoneSplitContainer
        {
            Dock = DockStyle.Fill,
            EnableKeyboardNavigation = true,
            EnableHotkeys = true,
            resetPositionHotkey = Keys.Control | Keys.R,
            toggleLockHotkey = Keys.Control | Keys.L
        };

        // Status label to display actions
        statusLabel = new Label
        {
            Dock = DockStyle.Bottom,
            Height = 30,
            TextAlign = ContentAlignment.MiddleCenter
        };

        // Subscribe to hotkey events if necessary
        splitContainer.KeyDown += (sender, e) =>
        {
            if (e.KeyData == splitContainer.resetPositionHotkey)
            {
                statusLabel.Text = "Resetting splitter position...";
                // Invoke reset logic (could be a method call)
            }
            else if (e.KeyData == splitContainer.toggleLockHotkey)
            {
                statusLabel.Text = "Toggling splitter lock...";
                splitContainer.IsSplitterLocked = !splitContainer.IsSplitterLocked;
            }
        };

        this.Controls.Add(splitContainer);
        this.Controls.Add(statusLabel);
    }
}
```

#### 3. Integrating Accessibility Attributes

This example emphasizes setting accessible names and roles to ensure compatibility with assistive technologies:

```csharp
public class AccessibleForm : Form
{
    private SiticoneSplitContainer splitContainer;

    public AccessibleForm()
    {
        InitializeComponent();
        splitContainer = new SiticoneSplitContainer
        {
            Dock = DockStyle.Fill,
            EnableKeyboardNavigation = true,
            EnableHotkeys = true
        };

        // Set accessible properties for assistive technologies
        splitContainer.AccessibleRole = AccessibleRole.Pane;
        splitContainer.AccessibleName = "Enhanced Split Container";
        splitContainer.AccessibleDescription = "Resizable split container with two panels that can be navigated using keyboard shortcuts.";

        this.Controls.Add(splitContainer);
    }
}
```

***

### Review

| Aspect                   | Details                                                                                                                                                          |
| ------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ease of Integration      | The keyboard navigation and hotkey features are implemented via simple property settings, making them easy to integrate and customize with minimal code changes. |
| Accessibility Compliance | Built-in accessibility attributes ensure that the control is compliant with assistive technologies, thereby enhancing usability for all users.                   |
| Flexibility              | Customizable key bindings provide developers the flexibility to define shortcuts that align with the application's overall user experience.                      |

***

### Summary

The Accessibility & Keyboard Navigation feature in the SiticoneSplitContainer control empowers developers to create accessible, keyboard-friendly interfaces. By enabling navigation and interaction through customizable key bindings and ensuring that the control is accessible to screen readers and other assistive technologies, this feature greatly enhances usability and inclusiveness in WinForms applications.

***

### Integration Steps

<table><thead><tr><th width="106">Step</th><th>Action</th></tr></thead><tbody><tr><td>Step 1</td><td>Instantiate the SiticoneSplitContainer and add it to your form, ensuring proper docking and layout settings.</td></tr><tr><td>Step 2</td><td>Enable keyboard navigation and hotkeys by setting <code>EnableKeyboardNavigation</code> and <code>EnableHotkeys</code> to true.</td></tr><tr><td>Step 3</td><td>Customize key bindings (e.g., <code>SplitterMoveLeftKey</code>, <code>SplitterMoveRightKey</code>, <code>swapPanelsHotkey</code>, <code>toggleOrientationHotkey</code>) as required.</td></tr><tr><td>Step 4</td><td>Set accessible properties (<code>AccessibleRole</code>, <code>AccessibleName</code>, <code>AccessibleDescription</code>) to improve compatibility with assistive technologies.</td></tr><tr><td>Step 5</td><td>Test the control's keyboard functionality and accessibility features across different environments and devices.</td></tr></tbody></table>

***

### Additional Resources

| Resource                     | Description                                                                                  | Example Link                                                                                                                 |
| ---------------------------- | -------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
| .NET Accessibility Overview  | Comprehensive documentation on implementing accessibility in .NET WinForms applications.     | [https://docs.microsoft.com/dotnet/desktop/winforms/advanced/](https://docs.microsoft.com/dotnet/desktop/winforms/advanced/) |
| WinForms Keyboard Navigation | Articles and tutorials on designing effective keyboard navigation for WinForms applications. | (Link to a recommended tutorial or blog post)                                                                                |

***

By following this comprehensive documentation and utilizing the provided code examples, developers can effectively integrate accessibility and keyboard navigation into their WinForms applications using the SiticoneSplitContainer control, thereby ensuring an inclusive and user-friendly experience.
