I have made the test setup in the picture. Layout under construction so using the time to work out what works for me (DCC++, JMRI, DCC++EX, wireless handheld throttle .....) Code is running on an Adafruit Trinket. Pins 2 and 7 are not available so had to move the keyboard and rotary encoder pins. Loco is a Hornby Morse Collieries (it was free!, but runs really nicely on DC and now DCC). Lais decoder, default address of 3.
Initial problem - the direction kept changing randomly. Added a pullup to the pin. The keyboard is about 30 years old but never used. Some keys work nicely (* and #, plus the rotary and button) but others generate multiple characters. Took a while not to have locos 1111, 2222, 3333 and 4444. Maybe some capacitors will help.
If I use a handheld throttle, I will probably get a 3.3V LCD module - they are a bit smaller so less chunky case needed.
Must add a big thanks to Mark for tidying up Dave Bodnar's code.
Cheers
Dave