4 ms·
This hack is exactly what I needed 2 days ago while working on a browser-based terminal app. My site will be secured with SSL/TLS, but I needed a way to make a
by deckar01 9y ago
This hack is exactly what I needed 2 days ago while working on a browser-based terminal app. My site will be secured with SSL/TLS, but I needed a way to make a content-editable span mask input like a password field. I already implemented it with a password input, but it doesn't wrap inline like a span does. It will be much cleaner to just add a class that masks the font.
- js2 9y agoA password field does more than just mask input. At least on macOS, it's also a secure input field where the OS ensures no other applications can see what is entered. Simply masking the font will imply to the user that their input is secure, when in fact it is not.
- deckar01 9y agoThat is a good reason to keep using a password input. I should probably intercept the keypress events and show nothing so that the password never even reaches the DOM. Then I wouldn't have to worry about the input growing/wrapping.
- throwaway2016a 9y agoMost terminal apps I use when you type in a password area nothing shows at all in the terminal (not even a mask). Though admittedly, that is not the best user experience for providing feedback.
- deckar01 9y agoI wonder if terminal apps hook into the same security input APIs from the OS that browsers are using for password inputs.
- aaronmdjones 9y agoThe terminal has a feature called "local echo". When you type something, it goes to the application (almost always its stdin file descriptor, but it can open /dev/tty and read that too). When local echo is enabled, the terminal also prints what you type. Applications that prompt for passwords simply (temporarily) disable local echo.