Skip to content

Commit 924a364

Browse files
committed
add helper methods for checking modifier state
1 parent f6fd6bb commit 924a364

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed

winit-core/src/keyboard.rs

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,6 +1749,61 @@ impl ModifiersState {
17491749
pub fn meta_key(&self) -> bool {
17501750
self.intersects(Self::META)
17511751
}
1752+
1753+
/// Returns `true` if the AltGraph key is pressed.
1754+
pub fn alt_graph_key(&self) -> bool {
1755+
self.contains(Self::ALT_GRAPH)
1756+
}
1757+
1758+
/// Returns `true` if the CapsLock key is toggled.
1759+
pub fn caps_lock_key(&self) -> bool {
1760+
self.contains(Self::CAPS_LOCK)
1761+
}
1762+
1763+
/// Returns `true` if the NumLock key is toggled.
1764+
pub fn num_lock_key(&self) -> bool {
1765+
self.contains(Self::NUM_LOCK)
1766+
}
1767+
1768+
/// Returns `true` if the ScrollLock key is toggled.
1769+
pub fn scroll_lock_key(&self) -> bool {
1770+
self.contains(Self::SCROLL_LOCK)
1771+
}
1772+
1773+
/// Returns `true` if the Fn key is pressed.
1774+
pub fn fn_key(&self) -> bool {
1775+
self.contains(Self::FN)
1776+
}
1777+
1778+
/// Returns `true` if the FnLock key is toggled.
1779+
pub fn fn_lock_key(&self) -> bool {
1780+
self.contains(Self::FN_LOCK)
1781+
}
1782+
1783+
/// Returns `true` if the KanaLock key is toggled.
1784+
pub fn kana_lock_key(&self) -> bool {
1785+
self.contains(Self::KANA_LOCK)
1786+
}
1787+
1788+
/// Returns `true` if the Loya key is pressed.
1789+
pub fn loya_key(&self) -> bool {
1790+
self.contains(Self::LOYA)
1791+
}
1792+
1793+
/// Returns `true` if the Roya key is pressed.
1794+
pub fn roya_key(&self) -> bool {
1795+
self.contains(Self::ROYA)
1796+
}
1797+
1798+
/// Returns `true` if the Symbol key is pressed.
1799+
pub fn symbol_key(&self) -> bool {
1800+
self.contains(Self::SYMBOL)
1801+
}
1802+
1803+
/// Returns `true` if the SymbolLock key is toggled.
1804+
pub fn symbol_lock_key(&self) -> bool {
1805+
self.contains(Self::SYMBOL_LOCK)
1806+
}
17521807
}
17531808

17541809
/// The state of the particular modifiers key.

0 commit comments

Comments
 (0)