U
U
urfinjazz2015-10-25 13:04:19
JavaScript
urfinjazz, 2015-10-25 13:04:19

How to rebind down keypress in Javascript?

Good afternoon!
Google Place Autocomplete is connected, it intercepts pressing the down (and up) key on the keyboard.

$('body').on('keydown', function (e) {
            console.log(e.which);
        }
    );

always returns a value except in these cases.
How to intercept the intercepted event?
The Google Maps API has an addListener method, but I don't see how it can be attached here.
Thank you in advance!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
U
urfinjazz, 2015-10-25
@urfinjazz

it turned out like this:

var input = document.getElementById('input');
new google.maps.places.Autocomplete(input);
google.maps.event.addDomListener(input,'keydown',function(e){
        if (e.keyCode == 40){
            console.log(e.keyCode)
        }
    });

A
Alexey, 2015-10-25
@Assada

You can, for example, reset the removeEventListener listener and rewrite it in your own way

R
Radiks Alijevs, 2015-10-25
@dedalik

There is a nice jQuery plugin with which you can override keystrokes on any jQuery.HotKeys event .

$(document).bind('keydown', 'ctrl+a', fn);

function fn() {
    alert('Hello man');
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question