'nodejs: how to press any key to continue and get the key value?

I have found some "press any key to continue" in nodejs, but I am unable to get the key that was pressed:

press any key to continue in nodejs

I also found some readline, but this needs to have enter key pressed.

I am looking for a solution that will wait for a single press key and returns the value of the pressed key

Like:

let key = await waitKeyPressed(); 
console.log("You pressed key:", key);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source