Ember-CLI: Barcode scanning

I have some generic code that listens for a certain sequence of keypresses and then registers that a physical barcode attached to a piece of paper has been scanned:

var pressed = false;
var chars =[];

$(window).keypress(function(e){
    if ((e.which>=65 && e.which <=90) || (e.which == 93) || (e.which >=97 && e.which <=122) || (e.which >=48 && e.which <=57)) {
        chars.push(String.fromCharCode(e.which));
    }
    if (pressed == false) {
        setTimeout(function() {
            if (chars.length >= 13) {
                var barcode = chars.join("");
                prefix = barcode[0] + barcode[1] + barcode[2];
            }
            chars = [];
            pressed = false;
            process(barcode)
        },500);
    }
    pressed = true;
});

On different pages the action that needs to be performed is different and I still need this listener to be able to process the scan. I am not sure how to design this sort of functionality in the Ember realm and was looking for some advice on what to do from experienced Ember devs.

I’m not entirely clear from your question what you’re trying to accomplish but if you want a thing that is accessible all over the place you may want to use ember’s dependency injection

The real question I have is where to put a script that is used everywhere that does not directly interface with a DOM action. There is no barcode component in my DOM, the action itself is connected to a user physically scanning a barcode that is on a paper in front of them.

Anyways, thanks for the lead on dependency injection, I will see if this solves my problem.