// Copyright (c) MudBlazor 2021 // MudBlazor licenses this file to you under the MIT license. // See the LICENSE file in the project root for more information. using System.Collections.Generic; namespace Connected.Services { public class KeyInterceptorOptions { /// /// Class of the target node which should be observed for keyboard events /// /// Note: this must be a single class /// public string TargetClass { get; set; } /// /// Report resize events in the browser's console. /// public bool EnableLogging { get; set; } = false; /// /// Intercept configuration for keys of interest /// public List Keys { get; set; } = new List(); } /// /// Configuration for preventDefault() and stopPropagation() control /// /// For PreventDown, PreventUp, StopDown and StopUp the configuration which key combinations should match /// is a Javascript boolean expression. /// /// Examples: /// For the examples, let's assume the Tab key was pressed. /// Note: for combinations of more than one modifier the following order of modifiers must be followed strictly: shift+ctrl+alt+meta /// /// * Don't prevent key down: /// PreventDown=null or PreventDown="none" /// * Prevent key down of unmodified keystrokes such as "Tab": /// PreventDown="key+none" /// * Prevent key down of Tab and Ctrl+Tab /// PreventDown="key+none|key+ctrl" /// * Prevent key down of just Ctrl+Tab /// PreventDown="key+ctrl" /// * Prevent key down of Ctrl+Tab and Shift+Tab but not Shift+Ctrl+Tab: /// PreventDown="key+shift|key+ctrl" /// * Prevent key down of Shift+Ctrl+Tab and Ctrl+Tab but not Shift+Tab: /// PreventDown="key+shift+ctrl|key+ctrl" /// * Prevent any combination of key and modifiers, but not the unmodified key: /// PreventDown="key+any" /// * Prevent any combination of key and modifiers, even the unmodified key: /// PreventDown="any" /// public class KeyOptions { /// /// Javascript keyboard event.key /// /// Examples: " " for space, "Tab" for tab, "a" for lowercase A-key. /// Also allowed: JS regex such as "/[a-z]/" or "/a|b/" but NOT "/[a-z]/g" or "/[a-z]/i" /// regex must be enclosed in two forward slashes! /// public string Key { get; set; } /// /// Subscribe down key and invoke event KeyDown on c# side /// public bool SubscribeDown { get; set; } /// /// Subscribe up key and invoke event KeyUp on c# side /// public bool SubscribeUp { get; set; } public string PreventDown { get; set; } = "none"; public string PreventUp { get; set; } = "none"; public string StopDown { get; set; } = "none"; public string StopUp { get; set; } = "none"; } }