From 0268bdc1a27fe9a037fa4d10fe839d4d24891b5f Mon Sep 17 00:00:00 2001 From: hannibal2 <24389977+hannibal00212@users.noreply.github.com> Date: Thu, 26 Oct 2023 00:30:14 +0200 Subject: code cleanup --- .../java/at/hannibal2/skyhanni/utils/KeyboardManager.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'src/main/java/at') diff --git a/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt index a1fac5387..d750b7696 100644 --- a/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/utils/KeyboardManager.kt @@ -17,15 +17,11 @@ object KeyboardManager { fun isControlKeyDown() = Keyboard.KEY_LCONTROL.isKeyHeld() || Keyboard.KEY_RCONTROL.isKeyHeld() fun isShiftKeyDown() = Keyboard.KEY_LSHIFT.isKeyHeld() || Keyboard.KEY_RSHIFT.isKeyHeld() - fun isPastingKeysDown(): Boolean { - val modifierHeld = if (SystemUtils.IS_OS_MAC) isCommandKeyDown() else isControlKeyDown() - return modifierHeld && Keyboard.KEY_V.isKeyHeld() - } + fun isPastingKeysDown() = isModifierHeld() && Keyboard.KEY_V.isKeyHeld() - fun isCopyingKeysDown(): Boolean { - val modifierHeld = if (SystemUtils.IS_OS_MAC) isCommandKeyDown() else isControlKeyDown() - return modifierHeld && Keyboard.KEY_C.isKeyHeld() - } + fun isCopyingKeysDown() = isModifierHeld() && Keyboard.KEY_C.isKeyHeld() + + private fun isModifierHeld() = if (SystemUtils.IS_OS_MAC) isCommandKeyDown() else isControlKeyDown() @SubscribeEvent fun onTick(event: LorenzTickEvent) { @@ -79,4 +75,4 @@ object KeyboardManager { } fun getKeyName(keyCode: Int): String = KeybindHelper.getKeyName(keyCode) -} \ No newline at end of file +} -- cgit