With a rudimentary function I make work the return of the key pressed as follows:

Flow:
[{"id":"44074231.bcd15c","type":"switch","z":"c32149c9.68d7d8","name":"","property":"payload","propertyType":"msg","rules":[{"t":"btwn","v":"960","vt":"num","v2":"970","v2t":"num"},{"t":"btwn","v":"975","vt":"num","v2":"985","v2t":"num"},{"t":"btwn","v":"995","vt":"num","v2":"1006","v2t":"num"},{"t":"btwn","v":"875","vt":"num","v2":"885","v2t":"num"},{"t":"btwn","v":"890","vt":"num","v2":"900","v2t":"num"},{"t":"btwn","v":"905","vt":"num","v2":"915","v2t":"num"},{"t":"btwn","v":"805","vt":"num","v2":"815","v2t":"num"},{"t":"btwn","v":"816","vt":"num","v2":"828","v2t":"num"},{"t":"btwn","v":"832","vt":"num","v2":"842","v2t":"num"},{"t":"btwn","v":"756","vt":"num","v2":"765","v2t":"num"},{"t":"btwn","v":"745","vt":"num","v2":"755","v2t":"num"},{"t":"btwn","v":"768","vt":"num","v2":"778","v2t":"num"},{"t":"btwn","v":"1015","vt":"num","v2":"1025","v2t":"num"},{"t":"btwn","v":"923","vt":"num","v2":"933","v2t":"num"},{"t":"btwn","v":"846","vt":"num","v2":"856","v2t":"num"},{"t":"btwn","v":"780","vt":"num","v2":"790","v2t":"num"},{"t":"else"}],"checkall":"true","outputs":17,"x":350,"y":1000,"wires":[["3ce27f8a.e574a"],["4619b4d3.2100ec"],["3d1348b2.2a51d8"],["d9985705.6c2f18"],["d69939c.05279c8"],["437121a3.66f67"],["d92e654a.72c858"],["7733d9c5.e03a98"],["395878b9.294958"],["f51d469e.624d08"],["6ea5a08b.b646f"],["ad92bb61.5018a8"],["ba832b56.779de8"],["72539223.ffb7dc"],["d8c2166c.c65018"],["3847b55f.55d59a"],["bf41963e.161038"]]},{"id":"4619b4d3.2100ec","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":700,"wires":[["64178689.4b6aa8"]]},{"id":"3d1348b2.2a51d8","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":740,"wires":[["64178689.4b6aa8"]]},{"id":"d9985705.6c2f18","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"4","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":780,"wires":[["64178689.4b6aa8"]]},{"id":"d69939c.05279c8","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"5","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":820,"wires":[["64178689.4b6aa8"]]},{"id":"437121a3.66f67","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"6","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":860,"wires":[["64178689.4b6aa8"]]},{"id":"d92e654a.72c858","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"7","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":900,"wires":[["64178689.4b6aa8"]]},{"id":"7733d9c5.e03a98","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"8","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":940,"wires":[["64178689.4b6aa8"]]},{"id":"395878b9.294958","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"9","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":980,"wires":[["64178689.4b6aa8"]]},{"id":"f51d469e.624d08","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"0","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1020,"wires":[["64178689.4b6aa8"]]},{"id":"6ea5a08b.b646f","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"*","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1060,"wires":[["64178689.4b6aa8"]]},{"id":"ad92bb61.5018a8","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"#","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1100,"wires":[["64178689.4b6aa8"]]},{"id":"ba832b56.779de8","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"A","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1140,"wires":[["64178689.4b6aa8"]]},{"id":"72539223.ffb7dc","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"B","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1180,"wires":[["64178689.4b6aa8"]]},{"id":"d8c2166c.c65018","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"C","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1220,"wires":[["64178689.4b6aa8"]]},{"id":"3847b55f.55d59a","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"D","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1260,"wires":[["64178689.4b6aa8"]]},{"id":"bf41963e.161038","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"incorrect","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":1300,"wires":[["64178689.4b6aa8"]]},{"id":"3ce27f8a.e574a","type":"change","z":"c32149c9.68d7d8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":560,"y":660,"wires":[["64178689.4b6aa8"]]},{"id":"64178689.4b6aa8","type":"function","z":"c32149c9.68d7d8","name":"","func":"\nreturn msg;","outputs":1,"noerr":0,"x":750,"y":780,"wires":[["6f0a1438.ff182c"]]}]
However if I can understand what I made wrong on the function I wrote originally will be great!!!!!!!
Now the big question is.... how I can make a function that collect 4 messages in a row and compare it with the stored code and return if is right or wrong code....
Thanks in advance