Return focus to visible boxes on ctrl release

This commit is contained in:
Andrew Tomaka 2013-08-04 12:33:18 -04:00
parent ec017915c2
commit d1478df484

View file

@ -49,7 +49,6 @@
$('button').corner('round 4px'); $('button').corner('round 4px');
$('#box').corner('round bottom'); $('#box').corner('round bottom');
$('#generate input').on('input', function() { $('#generate input').on('input', function() {
var root = $('#root').val(); var root = $('#root').val();
var master = $('#master').val() var master = $('#master').val()
@ -67,12 +66,26 @@
}); });
}); });
var currentFocus;
var lastFocus;
$(':input').focus(function() {
currentFocus = this;
});
$(document).keydown(function(e) { $(document).keydown(function(e) {
var keycode = e.keycode || e.which; var keycode = e.keycode || e.which;
if(keycode == 17) { if(keycode == 17) {
lastFocus = currentFocus;
$('#password').focus().select(); $('#password').focus().select();
} }
}); });
$(document).keyup(function(e) {
var keycode = e.keycode || e.which;
if(keycode == 17) {
lastFocus.focus();
}
});
</script> </script>
</body> </body>
</html> </html>