How to use digital-inputs as key like a real keyboard (Leonardo on OSX) ?

I want for a flight sim use some buttons at the digital-inputs and the shall act as a real keyboard. (Instead saw up a real keyboard and use a few keys of it. ;) )

All the examples are mostly only sending a sequence of chars. It's working for single commands (like Gear up/down), but not when the key must kept pressed.

Has anybody a working example ?

I figured out, you need, Keyboard.release(), a variable as cache and a litte delay() to avoid bouncing:

int key6 = 0;
if ( digitalRead(22) == LOW && key6 == 0) {; key6 = 1; delay(20);}
if ( digitalRead(22) == HIGH && key6 == 1) {Keyboard.release(KEY_6); key6 = 0; }