This is a yak-shaving situation. My app depends on devicechange for a key feature. I found on mac computer that when you close the lid or open the lid, the camera is removed then added (I know, super weird). Is there a way to detect if the laptop lid was closed or opened? I browsed through the list of possible events on mdn and didn't see anything glaring.
Asked
Active
Viewed 913 times
0

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129

jensengar
- 6,117
- 17
- 58
- 90
-
1How about adding a flag that flips every time you detect a change. They must start with it open, so a change must mean it's closed, another that it's open, etc. – Jan 29 '19 at 18:17
-
2https://stackoverflow.com/questions/4079115/can-any-desktop-browsers-detect-when-the-computer-resumes-from-sleep – jmargolisvt Jan 29 '19 at 18:18
-
@Chipster that's the plan, I was just looking for a way to actual detect that I need to set a flag. – jensengar Jan 29 '19 at 19:22
-
@jmargolisvt thanks for finding that. Unfortunately I don't think that will work for my case since the `devicechange` events get fired immediately and I'd need that `setInterval` to run before the second `devicechange` event. Again thank you though. – jensengar Jan 29 '19 at 19:35
-
@jensengar Ah. Okay. Got you. – Jan 29 '19 at 21:16