-1

I'm trying to make my Laravel application to access a link from an input field using ctrl pressed key and left click button.

My div looks something like this:

<input type="text" class="linkAccess" id="" name="" value="{{ $DBtable->tableColumn->value }}"

After I save my form and access it again, in this "input" I want my link to be shown and I want to access using that specific combination (ctrl+left click).

I have tried something like this:

$('.linkAccess').click( function (event) {
  event.preventDefault();
  if(true === event.ctrlKey) {

    /* Extract the value */
    var $link = $('.linkAccess');
    var value = $link.val();

    /* Filter out the requests that don't have a key word. */
    if('' !== value){
      $link.replaceWith( $("<a />").attr({"href" : value, "target":"_blank"}).html(value) );
    }
  }
})

Any Ideas?

LOG Oracle
  • 65
  • 9

1 Answers1

0
var keys = {};

$(document).keydown(function (e) {
    keys[e.which] = true;
});

$(document).keyup(function (e) {
    delete keys[e.which];
});

you can keep keys in array, and control in click event