Skip to content

Commit 18e032f

Browse files
committed
add helper methods for checking modifier state
1 parent 8eb2b1e commit 18e032f

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
@@ -1752,6 +1752,61 @@ impl ModifiersState {
17521752
pub fn meta_key(&self) -> bool {
17531753
self.intersects(Self::META)
17541754
}
1755+
1756+
/// Returns `true` if the AltGraph modifier is active.
1757+
pub fn alt_graph_key(&self) -> bool {
1758+
self.contains(Self::ALT_GRAPH)
1759+
}
1760+
1761+
/// Returns `true` if the CapsLock modifier is active.
1762+
pub fn caps_lock_key(&self) -> bool {
1763+
self.contains(Self::CAPS_LOCK)
1764+
}
1765+
1766+
/// Returns `true` if the NumLock modifier is active.
1767+
pub fn num_lock_key(&self) -> bool {
1768+
self.contains(Self::NUM_LOCK)
1769+
}
1770+
1771+
/// Returns `true` if the ScrollLock modifier is active.
1772+
pub fn scroll_lock_key(&self) -> bool {
1773+
self.contains(Self::SCROLL_LOCK)
1774+
}
1775+
1776+
/// Returns `true` if the Fn modifier is active.
1777+
pub fn fn_key(&self) -> bool {
1778+
self.contains(Self::FN)
1779+
}
1780+
1781+
/// Returns `true` if the FnLock modifier is active.
1782+
pub fn fn_lock_key(&self) -> bool {
1783+
self.contains(Self::FN_LOCK)
1784+
}
1785+
1786+
/// Returns `true` if the KanaLock modifier is active.
1787+
pub fn kana_lock_key(&self) -> bool {
1788+
self.contains(Self::KANA_LOCK)
1789+
}
1790+
1791+
/// Returns `true` if the Loya modifier is active.
1792+
pub fn loya_key(&self) -> bool {
1793+
self.contains(Self::LOYA)
1794+
}
1795+
1796+
/// Returns `true` if the Roya modifier is active.
1797+
pub fn roya_key(&self) -> bool {
1798+
self.contains(Self::ROYA)
1799+
}
1800+
1801+
/// Returns `true` if the Symbol modifier is active.
1802+
pub fn symbol_key(&self) -> bool {
1803+
self.contains(Self::SYMBOL)
1804+
}
1805+
1806+
/// Returns `true` if the SymbolLock modifier is active.
1807+
pub fn symbol_lock_key(&self) -> bool {
1808+
self.contains(Self::SYMBOL_LOCK)
1809+
}
17551810
}
17561811

17571812
/// The logical state of the particular modifiers key.

0 commit comments

Comments
 (0)