Page 1 of 1

Adafruit NeoKey Trinkey

Posted: Fri Aug 19, 2022 4:39 am
by mahbub

A few days back, I bought some NeoKey Trinky! (

Currently, I'm running a code that will print out a coffee emoji. Sometimes, when I press the key, it will type something else (usually ee or e), not coffee. As a result, it prints out the wrong emoji. It usually happens when I press the key after a long time, and for consecutive strokes, it works fine.

Could you please look at my code and see what's wrong? I'm using the following code example: ... le/

And here is the emoji code: ... ji/

Other info:
macOS Big Sur, Mac mini (M1, 2020)

Kind regards,

Re: Adafruit NeoKey Trinkey

Posted: Fri Aug 19, 2022 8:09 am
by FailingTinkerer
I suspect it's the character viewer that needs to be loaded into memory again. Basically, it has nothing to do with your script, but with how your OS handles keeping things in memory.

I suggest building in a 1-2 second delay if the key hasn't been activated for a while.

You can use time.monotic() for this purpose. ... .monotonic

Re: Adafruit NeoKey Trinkey

Posted: Fri Aug 19, 2022 7:24 pm
by mahbub
Thank you for the explanation. Where in the code should I use the time.monotic() ? Can I use time.sleep instead?

Re: Adafruit NeoKey Trinkey

Posted: Sat Aug 20, 2022 7:27 am
by FailingTinkerer
You could use time.sleep(1) after you send the emojii board shortcut. (ctrl+command+space)

But that would always make it slow. It's worth a shot though to see if that solves the problem. After that you can use monotic to make it faster if it's been recently triggered.

Basically like this:

Code: Select all

import time

keypressed = 'whateveryour key gpio pin is'
start_time = time.monotonic()

while True:
    if keypressed == True:
        time_difference = time.monotonic() - start_time
        start_time = time.monotonic() # update the start_time to the last time the key was pressed
        if time_difference < 2000: # I think 2000 = 2 seconds, not sure. Figure out a time that works with your OS.
            #execute recently pressed code
            #execute hasn't been triggered in a while code

Re: Adafruit NeoKey Trinkey

Posted: Sat Aug 20, 2022 7:40 pm
by mahbub
Thanks for the code example, I'll have a look. Thank you for your time!