Rotary encoder, for my tram simulator

Hi!
I would like to ask for help in an Arduino program. I have an Arduino Leonardo and a rotary encoder, called the ROT-1AB. I want to make a basic program that would press a button on my keyboard depending on the direction of the rotation. So far I have edited a built-in program in the software a little bit and tried it. I have a cruise control handle for a tram simulator. It has a braking (below 0 degree angle) and a speeding function (above 0 degree angle). In it’s default position it should press the Num+5 button on my keyboard. If I extract the „newPosition” from the „oldPosition”, I get the difference. If this number is above 0, it should press the Num+2 button on my keyboard and if this is below 0, it should press the Num+8 button. How do I measure the current position? And how do I active the keyboard buttons?
I attached a picture of my idea!

Thanks for the help in advance!

So far I have edited a built-in program in the software a little bit and tried it

Can you please post your existing code (between
** **[code]** **
and
** **[/code]** **
, the so-called code tags).

Here is my program in basic.

start_progi_enkoder_3.0.ino (1.25 KB)

Please re-read answer #1 and also read the instructions for posting (item 7)). :grinning: