Read a password
HTML, 20 bytes
<input type=password
Alternative: HTML + JavaScript, 51 bytes
Although the OP has confirmed that to be valid, here's a solution using JS for the purists!
<input id=i oninput=i.value=i.value.replace(/./g,8)
Vim, 36 bytes:
:im <C-v><CR> <C-v><esc>ZQ<CR>:au I<tab><tab> * let v:char=0<CR>i
This uses vim-key notation, so <C-v>
is control-v, <CR>
is enter, <esc>
is the escape key, and <tab>
is the tab key.
c is '0'
.
Here is a hexdump to prove the byte count is accurate:
00000000: 3a69 6d20 160a 2016 1b5a 510a 3a61 7520 :im .. ..ZQ.:au
00000010: 4909 0920 2a20 6c65 7420 763a 6368 6172 I.. * let v:char
00000020: 3d30 0a69 =0.i
This works by running the following two ex commands:
:imap <CR> <esc>ZQ
:autocmd InsertCharPre * let v:char=0
The first one means
:imap " Anytime the following is pressed in insert mode:
<CR> " (the 'enter' key)
<esc>ZQ " Then act as if the user instead pressed '<esc>ZQ' (close the buffer)
And the second one means
:autocmd " Automatically as vim runs:
InsertCharPre " Any time the user is about to insert a char
* " In any type of file
let v:char=0 " Then instead insert a '0' character
Ruby with Shoes, 29 characters
Shoes.app{edit_line secret:1}
Sample output: