Get a
Teensy USB Development Board or an equivalent microcontroller USB stick. Just make sure it has a native USB interface, not a serial-to-USB converter like most have.
For the Teensy, there is even an
USB keyboard example. Because it has a native USB interface, it can
be any kind of an USB device. In the example, it is configured as a USB keyboard. This is done at the hardware level; there is no driver software or anything involved. It will work on any operating system that supports USB keyboards.
All you need to program it is a mini-B USB cable and gcc-avr. It is both programmed and powered via the USB connector. You can use the digital I/O pins for a matrix (
W×
R buttons for
W outputs and
R inputs using only
W+
R digital I/O pins, buttons/switches, diodes, and resistors), and/or up to 12 or 8 (depending on model) analog I/O pins for sliders or rotary controls. There are also Hall effect sensors for magnetic sensing, and capacitive and inductive touch sensors for touch buttons you can easily use, if you need to hide the button in plain sight (say, inside your table surface, for example).
Standard push buttons or microswitches should work well for a simple button. For an example, see the
Reddit Upvote Button.
Look at the USB HID specs or Microsoft documentation which scancodes you want your buttons to generate (search the net for
USB scancodes for example). Personally, I would have it send different scancodes for odd and even keypresses. In Linux, I would use a small program to send a HID message -- similar to force feedback messages on gamepads -- that would light up a LED on the button when the recording really starts. You can supply say 10 to 15 mA current to a LED using an I/O pin from the Teensy just fine; just pick a suitable resistor for the LED to limit the current.
On the software side, you'll need to assign a keyboard shortcut (for the scancode you selected), to run the start-recording and stop-recording scripts. All Linux desktop environments (Gnome, KDE, XFCE, et al.) support keyboard shortcuts, usually with an easy-to-use interface under Keyboard Settings or Application Shortcuts. I don't use Windows, so I don't know whether you need some extra software or if it provides suitable functionality out of the box. (I don't really care about Windows at all, to be honest.)
In Linux I would use
~/.mything/ directory to hold the current recording, with
~/.mything/recording-pid containing the process ID of the running recording process (usually
arecord ). That way the stop-recording script would only need to send an INT signal to that pid. The start-recording script would run for the entire duration of the recording. It would simply notice the recording has ended, and move the completed recording to its final location, naming it properly. I believe these two scripts would need just a couple of dozen lines of code in Linux, even if written to be compatible with both ALSA and Pulseaudio audio systems. To enable it for a user, you'd only need to make sure the two scripts are installed on the system, then set up the two keyboard application shortcuts.