django / channels

Developer-friendly asynchrony for Django
https://channels.readthedocs.io
BSD 3-Clause "New" or "Revised" License
6.02k stars 793 forks source link

Question regarding code in tutorial part 1 #2010

Closed learningboiz closed 1 year ago

learningboiz commented 1 year ago

Hi,

In Part 1 of the Djano Tutorial,

I noticed that keyCode was used in the index.html chat template.

document.querySelector('#room-name-input').focus();
        document.querySelector('#room-name-input').onkeyup = function(e) {
            if (e.keyCode === 13) {  // enter, return
                document.querySelector('#room-name-submit').click();
            }
        };

MDN web docs mentions this property being depreciated.

Was wondering if there's any issues leaving it this way, or if it should be updated with lets say the key property.

carltongibson commented 1 year ago

Hi @ElijahQuiazon, good question.

It's still supported by all the main browsers https://caniuse.com/?search=keycode — but if you'd like to submit an updated version that would be cool. Fancy it?

Thanks.

learningboiz commented 1 year ago

Yup sure thing! I've gone ahead to submit a PR. It's my first time doing this so kindly let me know if I've missed anything out.

Cheers!