[Mac] MarginNote4 Secure Keyboard Entry

Hi MarginNote Support,

First, thanks for a great product!

I’m having a problem though, that may have been introduced in the 4.1.23 update.

When opening any PDF that is password protected, MarginNote prompts me to enter a password to unlock the PDF, and activates macOS’ “Secure Keyboard Entry” feature (which is a good thing, of course). The problem is that it never releases or revokes Secure Keyboard entry, which affects other applications.

Until I quit MarginNote, it keeps Secure Keyboard Entry enabled all the time.

I can see that MarginNote is the responsible application by running this command, after opening a protected PDF (after the password has been entered and used to decrypt, and the PDF is fully open in MarginNote):

~ > ioreg -l -w 0 \
     | perl -nle 'print $1 if /"kCGSSessionSecureInputPID"=(\d+)/' \
     | uniq \
     | xargs -I{} ps -p {} -o comm=
/Applications/MarginNote 4.app/Contents/MacOS/MarginNote 4

Because of this, tools like TextExpander, and many others that need to monitor keyboard input, cannot work at the same time as MarginNote, any time a protected PDF is open. I’m sure many of your users rely on applications like these.

I found this (few years old) stackoverflow post:

It sounds like MarginNote is calling function EnableSecureEventInput, but then not successfully calling DisableSecureEventInput?

Could the developers please check?

In my testing, the problem affects separate MarginNote installs on an Intel Macbook Pro running macOS 15.7 Sequoia (fully updated) and on a Mac Mini M4, running the macOS 26.0 Tahoe release version. I also tested MarginNote 3 with the same PDF files, and it does not have this problem.

1 Like

Unfortunately this is still an issue in the new 4.2.0 release (which sounds like a big one - expect the developers will be taking a few days off after that one!).

It’s very easy to re-create this:

  • print something (like this post) to PDF
  • open the PDF in the macOS Preview app, and go to File > Edit Permissions... and set a password (I set both passwords - one required to open the document and an owner password - I used the same value for both in the test).
  • Close the PDF, move it to the MarginNote documents folder.
  • Open the document in MarginNote. When prompted for the password, enter it. The document opens.
  • From now Secure Keyboard Entry is permanently on until MarginNote is closed.

As I said before this is a problem for some other apps, for example:

Text Expander

Karabiner Elements

Keyboard Maestro

…and many more.

I can add detail to the section on how to re-create this issue, with screenshots, if that would help?

If this is already an issue that has been acknowledged by the developers, please could someone from Support respond to this post? @adeline ?

Thanks!

Hello, actually, the somewhat awkward thing is that we haven’t been able to successfully reproduce the issue. Could you let us know if this problem only occurs on Mac, or if it also happens on iPad and iPhone

Thank you for looking into it!

Yes, the problem I was describing (as it affects me, at least) is on Mac only.

I have no problems using the same notebooks (with the same password protected PDFs) in MarginNote 4 for iPad.

Is there any way I can help further? Please let me know if there are any parts of the first or second post that are unclear. One thing I did think of after I posted the first comment in this thread, is that I might have been unclear about the command to run in the terminal. This is the command:

ioreg -l -w 0 \
     | perl -nle 'print $1 if /"kCGSSessionSecureInputPID"=(\d+)/' \
     | uniq \
     | xargs -I{} ps -p {} -o comm=

and if MarginNote is responsible for SecureKeyboardEntry being on, you should see the output, in response:

/Applications/MarginNote 4.app/Contents/MacOS/MarginNote 4

For me, (with a password protected PDF open in MarginNote) I can keep running that command and I’ll get the same output until I close MarginNote. Even then I might have to lock the screen and unlock it a few times. The ioreg command output may then show that loginwindow is still holding SecureKeyboardEntry for a few of those screen lock/unlocks before it finally gives no output, and things work normally again.

Here’s another free utility you could use to test with (used to set keyboard shortcuts, and won’t work with SecureKeyBoardEntry on): GitHub - koekeishiya/skhd: Simple hotkey daemon for macOS

OK, now I’ve tried the new release - v. 4.2.1

The problem is still there but seems a little different (but this is only based on some quick testing, just now - and I’m only referring to the macOS version, here).

Now, when I have a password-protected PDF open SecureKeyboardEntry is enabled whenever MarginNote is the focussed application (after the password has been successfully used to open the PDF). Whenever I am using another application (i.e. the Menu Bar doesn’t say “MarginNote 4”) SecureKeyboardEntry is off, but when I switch back to MarginNote it is on again.

I’m able to measure this by running the same ioreg command as before with a delay of 5 seconds to allow me to switch back to MarginNote before it runs, like:

sleep 5 && ioreg -l -w 0 \
     | perl -nle 'print $1 if /"kCGSSessionSecureInputPID"=(\d+)/' \
     | uniq \
     | xargs -I{} ps -p {} -o comm=

Doing this, I again see /Applications/MarginNote 4.app/Contents/MacOS/MarginNote 4 in response to the above command.

As I said in my first post, I see this behaviour on an M4 Mac Mini running Tahoe and on an Intel MacBook Pro running Sequoia.

I do want to ask, please: if you are still unable to reproduce this state at your end, are there other troubleshooting steps you could recommend? Any cache files I could delete, or MarginNote application settings I could try changing? I’d really love to get back to using MarginNote with my usual workflow again (which heavily uses some of the tools I’ve mentioned in previous posts).

I think the correct behaviour is to have SecureKeyboardEntry enabled only while the password prompt is displayed AND MarginNote is the focussed application, and that was MarginNote 4’s behaviour until quite recently. That is also how the macOS Preview application seems to behave (as does MarginNote 3).

Thank you for your detailed feedback! I will follow up on this issue and continue to make improvements.

Thank you - I appreciate the response!

Another update (4.2.2) and I’m still having this issue. Incredibly frustrating.

Could any other board members/MarginNote 4 users please try to see if they can replicate this? If I’m the only one experiencing this, then maybe somehow the problem is with my configuration, which would be good to know.

Does no-one else use any of the other tools I referenced in posts above?

I want to re-state that I also have MarginNote 3 installed and it behaves exactly as expected when providing passwords to unlock encrypted PDFs:

Secure Keyboard Entry is ONLY on when MarginNote 3 is displaying the dialogue box requesting the password AND MarginNote 3 is the focussed/active application.

After the password is entered, and the PDF is unlocked, Secure Keyboard Entry is no longer in force. MarginNote 4 leaves it on, system-wide.

I really need help on this, please. I’m too used to MarginNote 4 (which I really like) to go back to MarginNote 3 (and I should not have to, of course).