Is there a deno function for inputting prompt reply without pressing enter?
Normally, one has to press enter for the input to be accepted.
I was wondering if there was a version of prompt or confirm that lets you press a key, and that will automatically register (without pressing enter)
5 Replies
I wasn't able to find the answer to your question in the official Deno documentation. Deno's standard library provides a
prompt
function which requires the user to press enter after typing their input. This is the typical behavior for console input in many environments.
However, based on your message, it seems like you're looking for a way to capture a single keypress without the need to press enter. This kind of functionality usually involves more low-level handling of the terminal or command line interface and might not be directly supported by Deno's standard library.
Please note that the advice provided here is not based on the Deno documentation, and I would advise you to double-check the accuracy of this advice. If you need this functionality, you might need to look into third-party libraries or modules that provide more advanced terminal handling capabilities, or you might need to write a custom solution that interfaces with the system's terminal directly.Helpful Links:
Input Prompts - Deno by Example
addEventListener for keydown in terminal via deno? - Deno
Deno 1.19 Release Notes
Build a Cross-Platform CLI with Deno in 5 minutes
Deno 1.5 Release Notes
Deno 1.21 Release Notes
A list of every web API in Deno
Chat application with WebSocket | Deno Docs
maybe you can check out
deno.stdin
?This would read one byte aka one letter at a time without pressing enter:
There are probably better ways to do this…
Thanks! It works.
:deno_thumbs_up: