There's nothing fancy here. On password fields browsers have an auto-fill. Your method requires more effort compared to it.