Reading keypresses 32u4

Hi, im using an Arduino Pro Micro 32u4 enabled board, and I'm attempting to create a macros using the Keyboard.h library. My problem is that the pro micro can send key presses to the computer, but as far as i know is unable to read for presses. I'm using a laptop so using a wired external keyboard is out of the question. anyone got any ideas on how I can read and store key presses?

Can you please elaborate? Read presses from what?

Doesn't make sense to me. When I had a laptop, I often connected an external keyboard. Care to explain?

Continuing the discussion from Reading keypresses 32u4:

As said here I'm reading for key presses from my computer (windows 10), and the reason I say using an external keyboard is out of the question is because it's annoying to have to attach a bulky wired keyboard to my laptop that already has a keyboard every time I want to use my diy macros.

I'm not sure why you want the 32U4 to read the keypresses from the laptop's keyboard? One reason that I can think of is to have led indicators that e.g. indicate capslock but you might have other reasons in which case I'm curious about them.

The solution depends on the operating system. One possible solution (the only one I can think of at this moment) is that you intercept any key press at the operating system level and send that to the 32U4 over e.g. serial; you will have to write a PC application for that.

It was not quite clear to me. Now it is.

Fair enough; I thought that you were indicating that you couldn't physically connect a keyboard.

The reason I would like to be able to read and store key presses from the laptop keyboard, is because I'm making something called a macros. My idea is to press a push button wired to the Arduino micro, which tells the board to begin recording any presses. Once I'm done recording for key presses, I press the push button which ends the recording, saves the keys pressed and the duration it was held down, and the duration between the next key press. After all this I press the button one more time that repeats the recording over and over again exactly how I did it. Sorry if this is too complex😅

An example is, I press A, then B, then C, on my keyboard, I hold each down for 5 seconds, and there is a delay of 3 seconds between each press. I then tell the Arduino board to store this sequence in an array, then repeat it until the board is unplugged or reset.

I could try this, the arduino side is easy but I have no experience with Microsoft visual studio or creating applications in general. I was hoping there was a library for the 32u4 that allowed it to read keypresses. The keyboard.h library manages to send keypresses to the computer without any additional programs, so I was hoping there would be some similar library that reads for presses

So you basically want to teach the 32U4 a sequence of key presses. If so, as far as I can see, it should be reasonably easy to create a C# console application for that in Visual Studio; you will not have to do that at the operating system level intercepting the keyboard. The method that you're looking for is Console.ReadKey.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.