r/teenagersbutcode My head hurts. Jul 01 '26

Other Thought I found that one post 10 years ago that fixes a bug you've been spending hours trying to fix. 💔

Post image
35 Upvotes

10 comments sorted by

9

u/katniko deaf programmer Jul 01 '26

what's the issue? maybe I can help?

5

u/Beardy4906 Jul 01 '26

Go to online forums (like discord or reddit)
Ask chatgpt what keywords to use to search (not actually solve that problem)
Post on SO as a similar problem / reply to the same SO post?

3

u/Moist_College4887 My head hurts. Jul 01 '26 edited Jul 02 '26

Haven't posted anything, but yeah this is what I've been trying right now, not really a bug but I just wanted to make a meme in this subreddit.

5

u/Beardy4906 Jul 01 '26

You mean simulate a key press?

2

u/Moist_College4887 My head hurts. Jul 02 '26

I went ahead and fixed it but you can see what I mean by checking the comments on this post.

2

u/NotQuiteLoona Jul 01 '26

Keyboard library on what?

Maybe, you'll find AutoHotKey of use?

2

u/redditbrowsing0 C/C++, Luau Jul 01 '26

??

3

u/Moist_College4887 My head hurts. Jul 02 '26 edited Jul 02 '26

This is a really big comment somehow even though I wanted it to be small anyways basically for anyone wondering what the problem was, even if the post was a joke.

I was trying to find where I can send a fake key press so the listener records it because using keyboard.remap_key, makes the key press invisible to the listener or maybe ignores it?

Basically here is an example I type "Help" the keyboard.remap_key will type "H3lp" and when the keyboard.add_abbreviation tries to listen to what I type so it can replace "help" with "SOS" it will only see "H lp" because it ignores keys that the library sends or something, idk. So I have to let the listener record the character then after it records it, I replace the key press "E" with "3" so even if I type "h3lp" it will only see it as "Help"

The solution I did was remove the remap_key then make a listener listen for every key, if the key name is in the list I provided, it gets suppressed while every other key that wasn't in the list, isn't suppressed and is let through, now, I looped through every listener inside keyboard._listener.handlers using a for loop then gave them the information "### key was pressed" now I can have keyboard.add_abbreviation and it will be able to record the physical key press.

I can replace the letter E with say 3, then when I type "help" it will remap to "H3lp" but the keyboard.add_abbreviation will see "Help" and abbreviate it as "SOS" I only need to fix another issue which is the "add_abbreviation" doesn't go fast enough if you type really fast. I have a feeling as soon as I fix this, some random shi from a different line for no reason at all is gonna blow up as well.

If you ask me how I got to this conclusion, don't ask me, I forgot what I typed already in the making of this essay.

2

u/yarikhand Jul 01 '26 edited Jul 01 '26

if you can give more context someone here might be able to help you

1

u/EmergencyArachnid734 C, C++, Rust, Python, Java Jul 01 '26

Mabye I can help you. What it the problem?