GithubHelp home page GithubHelp logo

Comments (4)

creasty avatar creasty commented on August 29, 2024

Currently, it only intercepts keyboard events:

let eventMask = (1 << CGEventType.keyDown.rawValue) | (1 << CGEventType.keyUp.rawValue)

If you want to handle click events, include leftMouseDown & leftMouseUp to the mask.
c.f., https://developer.apple.com/documentation/coregraphics/cgeventtype

from keyboard.

aff avatar aff commented on August 29, 2024

Hi and many thanks for the suggestion. I´ve tried adding your suggested code, and even let eventMask = NSEvent.EventTypeMask.any.rawValue, but I can still not make it catch mouse events (clicks, taps, anything). Do keyboard and mouse events work differently?

from keyboard.

creasty avatar creasty commented on August 29, 2024

Please read the code more carefully.
It worked on my end.

index 961a81b..9a94825 100644
--- a/keyboard/AppComponent.swift
+++ b/keyboard/AppComponent.swift
@@ -20,6 +20,8 @@ final class AppComponent {
             if let manager = _eventManager {
                 return manager.handle(proxy: proxy, cgEvent: event)
             }
+        case .leftMouseDown:
+            print("leftMouseDown!")
         default:
             break
         }
diff --git a/keyboard/AppDelegate.swift b/keyboard/AppDelegate.swift
index bc39af6..84303b7 100644
--- a/keyboard/AppDelegate.swift
+++ b/keyboard/AppDelegate.swift
@@ -70,7 +70,7 @@ private extension AppDelegate {
     }

     func setupEventTap() {
-        let eventMask = (1 << CGEventType.keyDown.rawValue) | (1 << CGEventType.keyUp.rawValue)
+        let eventMask = (1 << CGEventType.keyDown.rawValue) | (1 << CGEventType.keyUp.rawValue) | (1 << CGEventType.leftMouseDown.rawValue)

         guard let eventTap = CGEvent.tapCreate(
             tap: .cghidEventTap,

from keyboard.

aff avatar aff commented on August 29, 2024

Fantastic, thank you! (I missed the AppComponent.swift part, I am sorry and I apologize)

from keyboard.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.