Chromebook Switch Window Key

482 views
Skip to first unread message

Mark Dostie

unread,
Jan 28, 2022, 2:36:54 PM1/28/22
to Chromium Extensions
On a Chromebook there is a special key usually found in the F5 (function key) position. If used with CTRL you can take a screenshot or you can tap it to switch windows quickly.

Unlike other keys on the keyboard it doesn't seem like you can detect when the user clicks on this key (it switches to a preview of other windows if you just hold it down). If you release it then the extension has no idea that it was even suspended.

Can anyone suggest a way to detect that this key has been pushed? Held down? Released?

Any suggestions are welcome.

Thanks,
Mark

Cuyler Stuwe

unread,
Jan 28, 2022, 2:40:26 PM1/28/22
to Mark Dostie, Chromium Extensions
What’s the purpose of this?

--
You received this message because you are subscribed to the Google Groups "Chromium Extensions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extens...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/6434bd69-7dc2-4ede-b243-93d1254c5698n%40chromium.org.

Mark Dostie

unread,
Jan 28, 2022, 4:58:42 PM1/28/22
to Chromium Extensions, salem...@gmail.com, Chromium Extensions, Mark Dostie
We have an extension which prevents students from cheating during exams. So they are using the Switch Window key to look at cheat sheets in the background. And we need to detect they are doing this so we can (a) prevent it or (b) report it happening.

hrg...@gmail.com

unread,
Jan 28, 2022, 5:21:49 PM1/28/22
to Chromium Extensions, dostie%t...@gtempaccount.com, salem...@gmail.com, Chromium Extensions
I can think of two possibilities.

FIRST:
Go to chrome://extensions/shortcuts and try to create a shortcut for any extension using that special key. If Chrome doesn't allow you use that key to define an extension shortcut, then try the second approach.


SECOND:
Create a dummy webpage with this code:
window.onkeydown = evt => console.log(evt);

Then try pressing that special key and see if you get a log event in the console. If you do, then try using evt.preventDefault() to override the function of that key.

If none of these approaches allows you to detect that key, then I'm afraid it wont be possible to do what you want.

Cuyler Stuwe

unread,
Jan 28, 2022, 5:45:18 PM1/28/22
to hrg...@gmail.com, Chromium Extensions, dostie%t...@gtempaccount.com, salem...@gmail.com
So essentially you’re just checking whether the window loses foreground/focus status, right?

Jackie Han

unread,
Jan 29, 2022, 5:25:40 AM1/29/22
to hrg...@gmail.com, Chromium Extensions, dostie%t...@gtempaccount.com, salem...@gmail.com
If none of these approaches allows you to detect that key, then I'm afraid it wont be possible to do what you want.

I think "Yes". Some special device keys, which are placed on F1-F12, can't be captured by javascript in a web page, like "mission control" and "applaunch" key on macOS, "Show Windows" key on chrome os.

Cuyler Stuwe

unread,
Jan 29, 2022, 10:30:43 AM1/29/22
to Jackie Han, Chromium Extensions, dostie%t...@gtempaccount.com, hrg...@gmail.com, salem...@gmail.com
Still seems like an XY issue; The problem isn’t ACTUALLY that you want to detect this key; The problem is that you want to check to see whether they’re switching windows/tabs to look at cheat sheets. I’m not even sure this behavior is necessary fixed only to that key; Perhaps that behavior is mappable to another key? Maybe it can be triggered even by e.g., a trackpad gesture?

Seems to me that you could explore visibility, rendering quirks, and/or a deadman switch depending on how a content script in the testing page reacts to this key being pressed.

If it’s true that execution of the extension is SUSPENDED during this time, that’s great; that’s detectable. Use the concept of a deadman switch. Send heartbeats seconds apart to various parts of the extension and/or a server. If these heartbeats don’t arrive within a reasonable time, and you can rule out all other plausible explanations for this, then it seems safe to label the user as having used that button (or any other mechanism) to suspend the extension ato potentially cheat. 

PhistucK

unread,
Jan 29, 2022, 10:37:12 AM1/29/22
to Jackie Han, hrg...@gmail.com, Chromium Extensions, dostie%t...@gtempaccount.com, salem...@gmail.com
Is this keyboard shortcut cancellable in full-screen mode? I know certain keyboard shortcuts are.

An extension can actually make sure they do not cheat by not allowing other windows to be focused, or by only allowing allow-listed URLs to be focused/navigated to.

PhistucK


Jackie Han

unread,
Jan 29, 2022, 11:16:02 AM1/29/22
to PhistucK, hrg...@gmail.com, Chromium Extensions, dostie%t...@gtempaccount.com, salem...@gmail.com
Cuyler and PhistucK's idea is very good. If possible, when a student starts the exam (e.g. click a button), then force close all other windows and tabs and keep this state until the end of the exam. Thus no other window will show when pressing the show windows key.

Mark Dostie

unread,
Jan 31, 2022, 11:08:24 AM1/31/22
to Chromium Extensions, Jackie Han, hrg...@gmail.com, Chromium Extensions, Mark Dostie, salem...@gmail.com, PhistucK
So a few things:
(a) the key does not appear when you look for keydown event or any key events
(b) it does not appear that you can cancel it in full-screen mode, I am staying in full screen and asserting it and it still allows them to leave
(c) it doesn't appear to be suspended only push into the background for a moment so the beats arrive on schedule though I need to test this more
(d) force-closing other Chrome windows works but because it is a Chromebook they can be running all sorts of apps including another browser like firefox which you cannot close at the start of the exam and you can't even determine that they are running so when they hit the key they can see all the other ones and even switch to them. I can force it back to my window once I lose focus but they have already been able to look at all the other windows in miniature by then
(e) once possibility is if there was a way to switch the top keys into function keys (there is a setting in CB) then it would turn into F5 and I could detect that and they could not switch out but I have not found any way to do this or detect if the user has done this so I can make them do it before the exam starts

Thanks,
Mark

PhistucK

unread,
Jan 31, 2022, 12:18:22 PM1/31/22
to Mark Dostie, Chromium Extensions, Jackie Han, hrg...@gmail.com, salem...@gmail.com
Oh, Linux/Android applications... Forgot about those.
Are those managed Chromebooks? If so, I think an administrator can disable Linux/Android support. A big hammer, but maybe it can be used only for the duration of the test (ask the students to restart at the beginning of the test to make sure the administrative settings are applied across the board). Re-enable it after the test.

PhistucK


Cuyler Stuwe

unread,
Jan 31, 2022, 2:04:05 PM1/31/22
to PhistucK, Chromium Extensions, Jackie Han, Mark Dostie, hrg...@gmail.com
Does document.hasFocus() (and/or the Chrome API equivalent) still report “true” when the user hits this key? How about document.visibilityState? That’s along the lines of what I would check. Seems like that’s really the crux of what you’re trying to determine — whether the user has something else up.
Reply all
Reply to author
Forward
0 new messages