0

I'm opening a Bootstrap modal with a jquery terminal inside by using a Mousetrap shortkey. Now i want to focus the terminal after opening the modal by shortcut, but it does not work. I tried to focus the id around and also some of the terminal classes. In Firefox console it did worked with .clipboard, but in javascript/jquery not.

$(document).ready(function() {
    Mousetrap.bind('ctrl+c', function(e) {
   $('.modal-content').css('background-color', '#000000');
   $('#console').modal('show');
    $('#console').focus();
});
});

Thank you!

phpDev937
  • 3
  • 3

1 Answers1

0

Set focus on the event that is called after opening the modal shown.bs.modal

$('YourModal').on('shown.bs.modal', function() {
    $("#console").focus();
})
Mathiasfc
  • 1,627
  • 1
  • 16
  • 24