Macro buttons to interact with games/computer

Hi everyone, thank you for hopping by,

I'm kind of new to Arduino and I try to learn everything on the go here based on my project. Unfortunately, I've tried many many times but couldn't find how I could realize my project. My project consist of:

  • Use a button on my arduino as PTT (push to talk) button for, by example, Teamspeak 3. This button may NOT interact with other things like typing a letter,... because when I push it, it would create a mess.

  • Use a switch which can toggle on/off my mic on, by example, Teamspeak 3.

Just know that I've tried it with the Keyboard.h but with my arduino Uno it doesn't work. Now I use the macro-button my keyboard with name 171 which weirdly does nothing so I use it as PTT.

Does anyone have any idea how I can even begin this project, some advise maybe or links, all help is welcome if this project is even possible.

Thank you in advance!

Are there (or can you set) keyboard shortcuts to take those actions in Teamspeak 3?

You need an Arduino with 'native' USB. A Micro, Due, Teensy and a few others will work.

Using keyboard.h is like having a second keyboard plugged into your system. Having it send a key code to the computer is like pressing that key on a second keyboard. For many games, this is OK. If you're actually typing a letter at the time then you don't want the key to appear in the letter.

With all of those above Arduinos you can use them as "HID" Human Interface Devices. Basically like a gamepad or joystick. If Teamspeak can be set up to use a joystick button as the PTT then that will work very well.

@Pert Thank you for your reply; yes, there is a way to do it with key-combinations. Thanks for the tip, now I know at least how I can fix the problem of not interfering with what I'm typing...

@MorganS Thank you for your reply; Is there another way to press keys without using the keyboard.h? I saw some random things on the internet using "buf" or something, is that possible?

The PC doesn’t really know or care how many keyboards are connected or where each keypress comes from. You can type “ABC” by pressing “A” on one keyboard, capslock on a second keyboard, “b” on another and sending “C” from an Arduino.

If your Teamspeak can only accept keys on a keyboard as input and you can’t type keys at the same time as doing whatever you are doing then you are out of luck. There is no solution to that. You need to search for another way to make it work.

From my understanding.. there is no way to 'tell' or have this only work for TEAMSPEAK3 (or whatever)..

Think of your mouse or keyboard currently connected to you PC.

If you hit the "A" key on the keyboard... it just spits out the "A" character to the PC (more or less)..

Your mouse/keyboard doesnt know or care about app is currently open or has focus.

It is the same scenario here..

If Teamspeak 3 allows you to set custom keyboard shortcuts and you assign very unique shortcuts (e.g. Ctrl + Alt + Shift + P) then it will be unlikely that any other program uses that shortcut. Yes, if you're typing at exactly the same time as the keyboard shortcut is sent then you will interfere with the shortcut and vice versa but the Arduino can send the shortcut very quickly and if you're the one pressing the button then likely you would not be typing at the same time anyway. So I really don't see why this is such a concern.

This post might be useful to you. It is code for gettng the "hidden" F13-F24 keys working with a due or pro micro (others HID compatible boards will be easy to adapt - those are just the boards I happen to have)

You could then bind "F13" to PTT within TS3, and "F14" to mute/enable mic etc.

I built mine using "guitar pedal" momentary stomp switches and have the keys bound within Open Broadcaster Studio for scene changes etc - no reason the same kind of tool wouldn't do what you need.

Is there another way to press keys without using the keyboard.h? I saw some random things on the internet using "buf" or something, is that possible?

When you code a USB-chip Arduino as HID, you can easily send keyboard, mouse, and/or stick data to the PC as part of your sketch. Just what the sketch takes as input is up to you, buttons or sensors don't matter, timing if you want, and when it's time to send to PC, it looks like a generic game controller to the PC.

PS -- if you want a keyboard & mouse connected, the Arduino Playground has how-to to connect PS2 mouse or PS2 keyboard right to Arduino pins. Walmart sells Logitech PS2 keyboard&mouse for $12.