How can I make keydown, keyup, keypress functions work on my end? - keypress

I am a beginner and taking a Udemy Course right now for JS, asked there also but yet no answers, that's why trying here now. The instructor writes this code, and then click on the console and then a letter on his keyboard and gets 'A key was pressed' on his console. However my console does not react, it is dead, nothing happens. oes anyone have any idea ? I looked up some youtube videos explaining key events, but none of them have this 'nothing happens' issue so was not helpful.
*I'm using VS Code App, and tried Brave and Firefox Browsers already.
Thanks in advance !
document.addEventListener('keydown', function () {
console.log('A key was pressed');
});

Related

Is There a Method or Extension (Firefox) to Always Show Captions on YouTube Videos?

This is either a programming request or a simple workaround...
Preface: I don't like Google and don't want to give YouTube any more support than I have to. However some creators I follow are only on YouTube.
Question: is there a way to always show closed captions (when available) when watching YouTube videos without being logged in/having an account? Is there an extension with this behavior?
Issue: When I watch multiple videos in a row, using the ?view=57 url trick and "Play All" button, the captions turn off when switching between videos... I have to enter the other room and hit the "c" button on the keyboard to turn them back on every time, which is inconvenient while streaming.
Action: I've searched for Firefox add-ons and extensions but their behaviors are all generically described... and I can't ascertain if they have this behavior. And many that talk about subtitles are you uploading your own .srt which is NOT what I'm trying to do.
Any help would be appreciated... it's a small but very frequently experienced annoyance and I feel like there must be some easy solution! Or... this could be a fun practice exercise for someone to release on github or something ;)
Thanks in advance.

Cannot tap a table cell in Xcode UI testing

I am writing Xcode UI test cases for a tableview. My code (Objective-C) is something like this
XCUIElement *elementCell = app.cells[#"AccessibilityIdentifierOfTheCell"];
XCTAssertTrue(elementCell.exists); // this assert passed
[elementCell tap]; // !!!??? crashed here
The testing crashes at the "tap" method.
I also tried Xcode's "Recode UI Test" to see how Xcode would catch the "tapping" behaviour in UI testing but, unfortunately, when I tapped on the cell the testing crashed as well and Xcode popped up this:
I got stuck here for quite a while and it will be highly appreciated if anyone can help me out.
Right after the question was posted I went back and tried again and, weirdly, it worked. I changed nothing. It may be that Xcode UI testing functionality is not steady yet.
Sorry for that.

Mac Safari Textarea Issue

I've done searches on this but can't find any information. On a Mac in Safari, I have a chat program and on the Customer Service side the textarea does not remove the previously typed answer. So the CSR has to highlight the text and then type her response. Any suggestions with how to clear the textarea? OR any suggestions what so ever? Thanks!
Unfortunately, the "chat program" in question was probably written to specifically handle "placeholder" text for IE, since IE doesn't recognize it like most other browsers.
I've tried to write simple jQuery code to get placeholder text to show up in IE before myself, but ended up abandoning it because it caused the effect you're describing in other browsers.
If you don't have direct control over the "chat program", I fear there is probably no way to "fix" this issue.

Simulate html listbox dropdown on trigger over other action

Please someone help me on the issue below.
I have a list dropdown box to be opened on trigger of a img div on top of it.
This works perfect in chrome, while it does not work in all other browsers like firefox, ie and others. I have a fiddle link ready which shows working example for chrome.
[link]http://jsfiddle.net/jNVwF/
Hope to hear from anyone of stack users.
Gone through Reference - Similar stacks
Firefox 5 dispatchEvent not working
(Not working, Implemented)
What am i doing wrong with fiddle link?
Thanks again.
Sajay.

Pause on any error/exception and pause on submit

I need a little orientation regarding Google Chrome debugger.
My application works only in Google Chrome because of well HTML5 support.
How can you pause on every single error/exception detected?
The source of this question it's the fact I'm doing a simple form submit with some Javascript validations.
On clicking the submit button I can see an error appearing in my Dev Tools Errors Frame, but it switch immediately to my PHP called on submit still in development, switching the page and therefore I can't read the error.
I've tried setting breakpoints and I've clicked on that pause on exceptions button, but it's not helping me, I'm doing something wrong.
I do not know completely how to use the debugger.
Have you considered trying to put a break point in a handler function for the window.onSubmit event?
Maybe something like this for jquery:
http://jsfiddle.net/7UZsk/27/
$(window).bind('submit',function(){
alert("submitting");
});​
This is the actual DOM event reference:
https://developer.mozilla.org/en/DOM/window.onsubmit

Resources