Class KeyInterceptor
This transient service binds itself to a parent element to observe the keys of one of its children. It can call preventDefault or stopPropagation directly on the JavaScript side for single key strokes / key combinations as per configuration. Furthermore, you can precisely subscribe single keystrokes or combinations and only the subscribed ones will be forwarded into .NET
public class KeyInterceptor : IKeyInterceptor, IDisposable
- Inheritance
-
KeyInterceptor
- Implements
- Inherited Members
- Extension Methods
Constructors
KeyInterceptor(IJSRuntime)
public KeyInterceptor(IJSRuntime jsRuntime)
Parameters
jsRuntime
IJSRuntime
Methods
Connect(string, KeyInterceptorOptions)
Connect to the ancestor element of the element(s) that should be observed
public Task Connect(string elementId, KeyInterceptorOptions options)
Parameters
elementId
stringAncestor html element id
options
KeyInterceptorOptionsDefine here the descendant(s) by setting TargetClass and the keystrokes to be monitored / suppressed
Returns
Disconnect()
Disconnect from the previously connected ancestor and its descendants
public Task Disconnect()
Returns
Dispose()
public void Dispose()
Dispose(bool)
protected virtual void Dispose(bool disposing)
Parameters
disposing
bool
OnKeyDown(KeyboardEventArgs)
[JSInvokable]
public void OnKeyDown(KeyboardEventArgs args)
Parameters
args
KeyboardEventArgs
OnKeyUp(KeyboardEventArgs)
[JSInvokable]
public void OnKeyUp(KeyboardEventArgs args)
Parameters
args
KeyboardEventArgs
UpdateKey(KeyOptions)
Update behavior of a registered keyoption The keystrike to update has to be monitored previously
public Task UpdateKey(KeyOptions option)
Parameters
option
KeyOptionsDefine KeyOption to update
Returns
Events
KeyDown
public event KeyboardEvent KeyDown
Event Type
KeyUp
public event KeyboardEvent KeyUp