SBoudrias/Inquirer.js

Feature request idea(input): toggle the transform function when CTRL+SPACE is clicked

matteosacchetto opened this issue · 2 comments

This idea comes to mind especially from using the password prompt, where being able to toggle the visibility of the password may be something useful. So, today I was wondering if this was something others could be interested in and may be worth up-streaming to the input prompt.

Basically the idea is that, when the user presses the CTRL+SPACE key combination, the transform function is temporarily bypassed to allow the user to see the non-transformed input. If CTRL+SPACE is pressed again, then the transform function is again activated. Whenever the user presses the ENTER key the transform function will be applied independently if it was previously bypassed or not.

Implementing such functionality is rather easy and could be versatile in different situations from just the use in the password prompt, though could be interesting to hear some feedback on this by other users of this library.

For reference here is an example of the modified input prompt with the suggested feature implemented.

https://stackblitz.com/edit/stackblitz-starters-ed1f1b?file=index.ts

Thank you,
Matteo

Hi, I'm not against introducing this change. But I have a few questions UX wise.

  1. How do we make this feature discoverable? (small help tip?)
  2. Is there common shortcuts used out there to unmask a password input? I'd like us to base ourselves on anything that is out there and potentially known already.

Lastly, we should make sure the feature can be turned off with an option. There might be users who don't want to allow unmasking.

Feel free to open a PR!

Hi, thanks for the reply

So, regarding your UX concerns:

  1. I think we could manage to show an help tip, we just need to think of a way for it to be helpful and not distracting
  2. I do agree with your view, though I have not yet found a common shortcut used by various applications. I found some references to ALT+F8, other to CTRL+SHIFT+C... I will look into this further

Regarding the last point, I would actually say it would be better if it is disabled by default and you have an option to enable it. This way, the feature can be added without it being a breaking change.

This weekend I will open a PR implementing the basic functionality