Nui
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Nui::WebApi::KeyboardEvent Class Reference

A keyboard event class. More...

#include <keyboard_event.hpp>

Inheritance diagram for Nui::WebApi::KeyboardEvent:
Inheritance graph
[legend]
Collaboration diagram for Nui::WebApi::KeyboardEvent:
Collaboration graph
[legend]

Public Member Functions

 KeyboardEvent (Nui::val event)
 
bool altKey () const
 Returns a boolean value that is true if the Alt (Option or ⌥ on macOS) key was active when the key event was generated.
 
bool ctrlKey () const
 Returns a boolean value that is true if the Ctrl key was active when the key event was generated.
 
bool shiftKey () const
 Returns a boolean value that is true if the Shift key was active when the key event was generated.
 
bool metaKey () const
 Returns a boolean value that is true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the key event was generated.
 
std::string code () const
 Returns a string with the code value of the physical key represented by the event.
 
bool isComposing () const
 Returns a boolean value that is true if the event is fired between after compositionstart and before compositionend.
 
std::string key () const
 Returns a string representing the key value of the key represented by the event.
 
int location () const
 Returns a number representing the location of the key on the keyboard or other input device.
 
bool repeat () const
 Returns a boolean value that is true if the key is being held down such that it is automatically repeating.
 
- Public Member Functions inherited from Nui::WebApi::UiEvent
 UiEvent (Nui::val event)
 
long detail () const
 
Nui::val sourceCapabilities () const
 
Nui::val view () const
 
- Public Member Functions inherited from Nui::WebApi::Event
 Event (Nui::val event)
 
bool bubbles () const
 A boolean value indicating whether or not the event bubbles up through the DOM.
 
bool cancelable () const
 A boolean value indicating whether the event is cancelable.
 
bool composed () const
 A boolean indicating whether or not the event can bubble across the boundary between the shadow DOM and the regular DOM.
 
Nui::val currentTarget () const
 A reference to the currently registered target for the event.
 
bool defaultPrevented () const
 Indicates whether or not the call to event.preventDefault() canceled the event.
 
EventPhase eventPhase () const
 Indicates which phase of the event flow is being processed.
 
bool isTrusted () const
 Indicates whether or not the event was initiated by the browser (after a user click, for instance) or by a script (using an event creation method, for example).
 
Nui::val target () const
 A reference to the object to which the event was originally dispatched.
 
std::chrono::milliseconds timeStamp () const
 The time at which the event was created (in milliseconds).
 
std::string type () const
 The name identifying the type of the event, e.g., "click", "hashchange", or "submit".
 
std::vector< Nui::valcomposedPath () const
 The composedPath() method of the Event interface returns the event's path which is an array of the objects on which listeners will be invoked.
 
void preventDefault () const
 Cancels the event (if it is cancelable).
 
void stopImmediatePropagation () const
 For this particular event, prevent all other listeners from being called.
 
void stopPropagation () const
 Stops the propagation of events further along in the DOM.
 
- Public Member Functions inherited from Nui::ValWrapper
 ValWrapper (Nui::val valObject)
 
virtual ~ValWrapper ()=default
 
 ValWrapper (ValWrapper const &)=default
 
 ValWrapper (ValWrapper &&) noexcept=default
 
ValWrapperoperator= (ValWrapper const &)=default
 
ValWrapperoperator= (ValWrapper &&) noexcept=default
 
Nui::val const & val () const &noexcept
 
Nui::val val () &&noexcept
 
 operator Nui::val const & () const &noexcept
 
 operator Nui::val () &&noexcept
 

Additional Inherited Members

- Protected Attributes inherited from Nui::ValWrapper
Nui::val val_
 

Detailed Description

A keyboard event class.

See also
https://developer.mozilla.org/en-US/docs/Web/API/Element/keyup_event

Constructor & Destructor Documentation

◆ KeyboardEvent()

Nui::WebApi::KeyboardEvent::KeyboardEvent ( Nui::val  event)
explicit

Member Function Documentation

◆ altKey()

bool Nui::WebApi::KeyboardEvent::altKey ( ) const

Returns a boolean value that is true if the Alt (Option or ⌥ on macOS) key was active when the key event was generated.

◆ code()

std::string Nui::WebApi::KeyboardEvent::code ( ) const

Returns a string with the code value of the physical key represented by the event.

Warning: This ignores the user's keyboard layout, so that if the user presses the key at the "Y" position in a QWERTY keyboard layout (near the middle of the row above the home row), this will always return "KeyY", even if the user has a QWERTZ keyboard (which would mean the user expects a "Z" and all the other properties would indicate a "Z") or a Dvorak keyboard layout (where the user would expect an "F"). If you want to display the correct keystrokes to the user, you can use Keyboard.getLayoutMap().

Returns
std::string

◆ ctrlKey()

bool Nui::WebApi::KeyboardEvent::ctrlKey ( ) const

Returns a boolean value that is true if the Ctrl key was active when the key event was generated.

◆ isComposing()

bool Nui::WebApi::KeyboardEvent::isComposing ( ) const

Returns a boolean value that is true if the event is fired between after compositionstart and before compositionend.

◆ key()

std::string Nui::WebApi::KeyboardEvent::key ( ) const

Returns a string representing the key value of the key represented by the event.

◆ location()

int Nui::WebApi::KeyboardEvent::location ( ) const

Returns a number representing the location of the key on the keyboard or other input device.

A list of the constants identifying the locations is shown in Keyboard locations.

◆ metaKey()

bool Nui::WebApi::KeyboardEvent::metaKey ( ) const

Returns a boolean value that is true if the Meta key (on Mac keyboards, the ⌘ Command key; on Windows keyboards, the Windows key (⊞)) was active when the key event was generated.

◆ repeat()

bool Nui::WebApi::KeyboardEvent::repeat ( ) const

Returns a boolean value that is true if the key is being held down such that it is automatically repeating.

◆ shiftKey()

bool Nui::WebApi::KeyboardEvent::shiftKey ( ) const

Returns a boolean value that is true if the Shift key was active when the key event was generated.


The documentation for this class was generated from the following files: