How Software Deals with Key Presses - Computerphile

  Рет қаралды 71,802

Computerphile

Computerphile

5 жыл бұрын

Once you've pressed a key on the keyboard and the signal gets to the computer, what happens next? Dr Steve Bagley on the software side of a key-press.
Key Presses pt1: • What Happens When I Pr...
/ computerphile
/ computer_phile
This video was filmed and edited by Sean Riley.
Computer Science at the University of Nottingham: bit.ly/nottscomputer
Computerphile is a sister project to Brady Haran's Numberphile. More at www.bradyharan.com

Пікірлер: 159
@KenHilton
@KenHilton 5 жыл бұрын
10:38 All keys are equal, but some keys are more equal than others.
@procactus9109
@procactus9109 5 жыл бұрын
All my keys are black
@Tahgtahv
@Tahgtahv 5 жыл бұрын
At the hardware level on the keyboard, not all keys are treated equal. That's because most modifier keys are often held down while another key is pressed, and if you have too many at once, that could cause more of a path than a single intersection in the matrix. On gaming keyboards, there might be special care on further keys, such as WASD, in order to detect them better.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
That was discussed in part 1. It’s why the matrix is scanned, not simply fed with static voltages.
@jkobain
@jkobain 2 жыл бұрын
@@lawrencedoliveiro9104 when you have a simple XY (X scanning, Y receiving) matrix of just switches, closing switches of keys (0, 0), (0, 1) and (1, 1) will result in logical 1 on (1, 0) position as well, because Y line 0 will be tied up high to logical 1 voltage from X line 1 to Y 1 line via (1, 1), then from Y 1 line to X 0 line via (0, 1), then from X 0 line to Y 0 line via (0, 0). Therefore you'll have logical 1 on both lines Y 0 and Y 1, while you expected to have logical 1 on only Y 1, since the (1, 0) button isn't pressed, but this «phantom» keypress will be there. But better not trust me, just go draw it for yourself! This is why they either add diodes to prevent reverse current flow, or separate them better, or do both.
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
4:05 Not just a security issue: think about languages that require a front-end processor (e.g. Chinese/Japanese/Korean) to translate keystrokes into a large character set: putting this in userland makes it more flexible, replaceable, configurable etc.
@HamousIceCreamTruck
@HamousIceCreamTruck 5 жыл бұрын
my keypresses go thru so much refinement, and yet my posts are still terrible
@andruwne802
@andruwne802 5 жыл бұрын
This one wasn't.
@Dawwwg
@Dawwwg 5 жыл бұрын
You probably have a bug - or even a design flaw - in your message-filtering loop. Make sure not to flip too many bits and suppress the event-bubble, otherwise event-storms might cause stutter ...
@KnakuanaRka
@KnakuanaRka 5 жыл бұрын
I’d chalk that up to user error.
@Dawwwg
@Dawwwg 5 жыл бұрын
Yeah, the root-cause: PEBKAC
@BlankBrain
@BlankBrain 5 жыл бұрын
Two things not addressed were: how key bounce is handled and how key release/repeat is handled. A long time ago, I wrote a GUI for DOS that looked a lot like the NetWare interface. The keyboard was relatively easy to handle. The complex part was handling keyboard/mouse interactions.
@benoitrousseau4137
@benoitrousseau4137 5 жыл бұрын
The IBM model M gave special treatment to the modifier keys. It used a matrix where pressing 3 or more keys would sometimes not register all of them properly. Since the modifier keys are by design intended to be pressed with other keys, they were made immune to that issue with a dedicated line.
@silkwesir1444
@silkwesir1444 5 жыл бұрын
as far as i know, many (most?) keyboards do that, not just IBM Model Ms
@Falcrist
@Falcrist 5 жыл бұрын
That's not really "different treatment" as much as "different wiring". A keypress is still just a keypress.
@PanoWorks
@PanoWorks 5 жыл бұрын
Yeah, would have been nice if they'd covered the 'N-key rollover' issue in the hardware edition. There's still limitations on many keyboards and wiring can be very era-dependent. E.g. once WASD controls for gaming became popular, practically all keyboard manufacturers ensured that you could press those keys, along with e.g. shift, alt, ctrl, space (activation/jump buttons) and a whole bunch more at the same time and have them recognized at the same time. Maybe they can do a short video on that as an addendum, though I'm sure there's tons of videos on the subject already.
@dykodesigns
@dykodesigns 5 жыл бұрын
The handling of keys pressed by the window server is an iterresting point as this is where window focus stealing can have some side effects. Like typing in a password and whilst some application loads (like a texteditor of word) and it’s main window pops up in the front and your keystrokes get sent to word instead of the password dialogue box. This is a serious issue that still hasn’t been fixed in windows and would make a nice suggestion for a computerphile video.
@nebuleon
@nebuleon 5 жыл бұрын
There is a fair amount of work in some desktop environments to prevent focus stealing. DEs like KDE and GNOME (and, I assume, LXDE, XFCE and others) expose an input setting called _Focus stealing prevention,_ which allows you to keep focus in a window if you're actively typing into it or have your mouse over it - or even at all times! - and is implemented by the X Window System or Wayland display server. In Windows Vista or later, if you're typing into the secure desktop implemented by _User Account Control,_ no user program can steal the focus from that *at all.* The reverse problem, which is for _User Account Control_ to receive clicks that were meant for a user program and happen to be right above the Yes button in the prompt, has a mitigation: if you were clicking or typing, the secure desktop doesn't pop up, and the window that requested it merely flashes to request your attention. The secure desktop pops up when you next click its task bar entry. That doesn't help user programs' password prompts, but it's a start!
@dykodesigns
@dykodesigns 5 жыл бұрын
The problem that I often experience in windows 7 and 10 is that a splash screen of an application steals focus from an application that is already running. I often start multiple programs in sequence, for instance Excel, Autodesk revit and Autocad. Autocad has a command line and when I'm working in Word I let autocad start in the background. After a while the splash screen appears and it steals focus. It then bring Word back on top but once autocad has completely loaded, Word loses focus and everthing I type gets passed to autocad's command line. This is such a fundamental flaw in windows that they've never fixed and I doubt if they ever will, but it is super annoying. Does the secure desktop only work on enteripse versions of windows or does that also work on the home edition?
@nebuleon
@nebuleon 5 жыл бұрын
dykodesigns2yt: "Does the secure desktop only work on enterprise versions of Windows [...]?" The secure desktop is the dimmed version of the desktop where only security-sensitive UAC prompts appear and anything else becomes temporarily unresponsive. You can't exactly make use of it in user programs like Word and AutoCAD to work around splash screens' focus stealing, unfortunately.
@sonias1693
@sonias1693 5 жыл бұрын
this is really cool and helpful cause Im studying for my exam atm, thank you!
@orlovsskibet
@orlovsskibet 5 жыл бұрын
Probably not gonna write a program like that, but you could. Me: Opens up the code editor Name your project: Tom and Jerry keyboard tool.c
@Rolfdv395
@Rolfdv395 5 жыл бұрын
Don't keep this video on "hidden" please
@Furiends
@Furiends 5 жыл бұрын
Here's how keys are handled on Linux: Low level kernel - Interrupt handler Kernel modules/device drivers (for USB) - uhci_hcd or ohci_hcd or ehci_hcd - usbcore - usbhid or usbmouse + usbkbd Kernel modules/device drivers (for IBM PS/2 mini-DIN and AT connectors) - atkbd Kernel subsystem - ioctls - evdev User-space - libevdev (library for device events) Window server - xf86-input-evdev (direct input handler) or - libinput -> xf86-input-libinput (libinput via X) or - libinput -> Weston (libinput via Wayland) For X: - X window system - X client (Xlib/XCB or toolkit like Qt) For Wayland - Weston - Wayland client Other software was involved like udev to detect which device to use and extensions like X keyboard extension (Xkb) to interpret key codes which is shared by X and Wayland.
@AttilaAsztalos
@AttilaAsztalos 5 жыл бұрын
Operating systems are these ingenious pieces of software that make sure you can type at least half a sentence before realizing that your key presses go to absolutely none of the windows on your screen at the moment.
@lostwizard
@lostwizard 5 жыл бұрын
I suspect a lot of the increased latency is down to font rendering and window redraws. Given that older systems had hardware text screens that you just had to put a character code into a memory location to have a letter show up on screen, that would allow for much faster processing than on modern bitmap displays. Of course, there's also more latency when you start throwing in things like USB stacks instead of the PS2 connection, and several layers of handlers (device drivers, window systems, etc.) and more complex key code handling (compose keys, etc.).
@Keltheran
@Keltheran 5 жыл бұрын
It would be interesting to compare a normal computer and keyboard with a motherboard built for gaming (with dedicated USB ports) and a gaming grade keyboard, maybe all us gamers have been even more scammed then we know :-)
@lostwizard
@lostwizard 5 жыл бұрын
Keltheran That would be interesting. I do expect most of the latency is in the comms (USB/PS2/etc.) up through the operating system (drivers, GUI, libraries). There is one thing about a lot of gaming keyboards, though. They take special pains to allow more combinations of simulateous keypresses to work properly, and possibly a higher number of simultaneous keypresses overall. I doubt there's much overall improvement in keypress detection latency in the keyoard itself compared to non-gaming keyboards, though.
@kaitlyn__L
@kaitlyn__L 5 жыл бұрын
Latency from when the signal is received is one thing that likely won't change, but the ability to support increased poll rates might make a difference? Just in decreasing the time before the signal even gets "sent". I personally don't notice with a keyboard, but I do with mice. I tried setting my mouse's poll rate to the minimum, which generic mice use, and it felt like I had path smoothing turned on. It was most noticeable because it was a "no acceleration" mouse, which generic mice don't tend to be either (although you can change the registry or equivalent to remove acceleration, the sensors and controllers in the mice still has some.). I wonder what the equivalent to max poll rate was for PS/2 mice, given that that's interrupt based. There must be a practical limit to that, whether it be CPU speed or microcontroller speed, or sensitivity of the rollers the ball moves in, etc. Hmm.
@fburton8
@fburton8 5 жыл бұрын
I find the increased latency thing fascinating (in the horribly fascinating sense) - that it increases even when the processor, bus speeds etc. increase by orders of magnitude. Boot times also seem mind-bogglingly slow, relatively speaking.
@brylanjacobs9139
@brylanjacobs9139 5 жыл бұрын
This is brilliant!!
@edgarbonet1
@edgarbonet1 2 жыл бұрын
Re “are all keys treated equally?”: In the USB HID protocol, modifier keys are handled in a special way: their state is sent as a bitmap (8 modifiers in one byte). For all other keys, the keyboard sends a list of the keys that are currently pressed.
@okaro6595
@okaro6595 5 жыл бұрын
Om modern PCs (Since PC/AT) the lights are handled by the computer. On the original IBM PC there were no lights and the interface was unidirectional. I had a clone keyboard that had lights and they were handled by the keyboard. The problem was that if the code for example numlock on (many calculator programs did) the lights got out of sync so I ended up covering the light.
@sajukkhar
@sajukkhar 5 жыл бұрын
I always test if the computer is hanged if when i press the num lock key if the led responds or not
@EscapeMCP
@EscapeMCP 5 жыл бұрын
20 years in IT and that trick hasn't failed me yet.
@iabervon
@iabervon 5 жыл бұрын
I recently had that fail: the keyboard controller on my laptop stopped working, so numlock didn't get detected, but the USB system was still working, so I could move the cursor with my trackball. I didn't figure out what was actually wrong, but my guess was that the kernel decided the interrupt was stuck and started ignoring it.
@EscapeMCP
@EscapeMCP 5 жыл бұрын
All bets are off on laptops. You never really know how they are connected internally (USB, PS/2, SPI, I2C)?
@Robstafarian
@Robstafarian 3 жыл бұрын
This is why I have always set my firmware to activate the num lock LED on boot.
@romanemul1
@romanemul1 5 жыл бұрын
A very nice continuation of this video will be about processor modes or windows data structures. Oh btw i like his shirt.
@DrewWalton
@DrewWalton 5 жыл бұрын
On the PC, keyboard interrupts only occur with PS/2 keyboards. For USB keyboards the kernel has to poll the keyboard for key presses.
@jkobain
@jkobain 2 жыл бұрын
- The short answer is yes. While the long answer is no. While, actually, «yes» is 50% longer than «no» is.
@danp9944
@danp9944 5 жыл бұрын
Computerphile, can you do more videos on the Linux OS? Or maybe how they are setup, etc. Or do a video on how duel-booting works (like a full in-depth explanation on what happens behind the scenes) Those are just my suggestions
@TDGalea
@TDGalea 5 жыл бұрын
Dual booting really isn't complicated enough to warrant it. It's literally a case of the bootloader (GRUB, Windows Boot Manager, etc.) doing very similar to you finding the right program to run
@danp9944
@danp9944 5 жыл бұрын
Thomas Galea oh well. It was worth a shot at suggesting it :)
@jeremyelliot4831
@jeremyelliot4831 5 жыл бұрын
Thomas key presses could be described in the same simplistic way. What's the difference between GRUB and Windows Boot Manager? How do I stop a new Windows installation from overwriting my GRUB boot loader?
@akhil3309
@akhil3309 5 жыл бұрын
Please do a video like this on processor and how it works please..
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
10:05 With Linux, was that measured in a GUI window (which GUI?) or in a text console?
@salaiimp
@salaiimp 5 жыл бұрын
Is it possible to get some idea about ghost pressing of keys and the love for mechanical keyboards?
@MuhammadAli-cz7ez
@MuhammadAli-cz7ez Жыл бұрын
I have a spesific question about keyboards. If we want to add a special key which is not found on a standart keyboard such as alpha(latin letter)to our keyboard, how can do it that? If you explain that I would be so grateful.
@superfluidity
@superfluidity 5 жыл бұрын
I think the operating system must send events even if just a modifier key is pressed, or at least have the ability to do it sometimes. In Jetbrains IDEs you can open a search box by pressing shift twice.
@crystalsoulslayer
@crystalsoulslayer 5 жыл бұрын
Yeah, I'm not sure if the event is sent and the program ignores it, or if the event is only sent if the program asks it to be. The latter would probably be a tad more efficient.
@ciano5475
@ciano5475 5 жыл бұрын
On Windows, you have two events, Key Press and Key Release, and your program decides what to do.
@0LoneTech
@0LoneTech 5 жыл бұрын
Yes, shift keys get press/release events just like other keys. Since they're meant to be held they also frequently have dedicated lines (such as being outside the scanning matrix, or having dedicated bits in a HID report). In the OS level, they'll activate keyboard mapping states such as capitals for decoding other keys, but not decode to printable letters themselves. So a program waiting for text won't notice them, but a program looking at held keys will.
@crystalsoulslayer
@crystalsoulslayer 5 жыл бұрын
Cool. Thanks for the explanation!
@kc9scott
@kc9scott 5 жыл бұрын
That's unfortunate. The shift key by itself ideally shouldn't do anything. When I'm waiting for the computer to finish doing something, I like to tap out various rhythms on one or both of the shift keys.
@StefanoPapaleo-TS
@StefanoPapaleo-TS 5 жыл бұрын
Tom & Jerry programmes coming up in 3, 2, 1...
@okaro6595
@okaro6595 5 жыл бұрын
I recall reading that at least on IBM PC the insert key did not have hardware repeat. I think the FN key is handled internally by the keyboard. The keyboard then interprets the combination and sends it to the computer. I for example have a keyboard where FN Down is PgDn. If I press these a keystroke monitor shows that I press just PgDn.
@TDGalea
@TDGalea 5 жыл бұрын
Yes, FN is handled in the keyboard's hardware.
@StarkRG
@StarkRG 5 жыл бұрын
Well now we need a video on n-key rollover.
@PhilBoswell
@PhilBoswell 5 жыл бұрын
So at what level is Ctrl-Alt-Del or local equivalent processed in modern computers? I seem to recall that in older PCs this was handled inside the keyboard, which was just one of the reasons that a PC would refuse to operate without a keyboard attached…
@cyril021944
@cyril021944 5 жыл бұрын
Maybe an interrupt with a higher priority.
@superfluidity
@superfluidity 5 жыл бұрын
In Windows that's the 'secure attention sequence'. It's handled by the operating system, and its supposed to give some security because it can never be handled by an application. Therefore anything that reacts to ctrl-alt-del is presumably a genuine part of windows and you should be able to trust it with typing in your windows password.
@ciano5475
@ciano5475 5 жыл бұрын
On Windows is a special sequence and is handled in the kernel.
@0LoneTech
@0LoneTech 5 жыл бұрын
It was not handled in hardware on PCs, but it was on Amiga computers (well, control-amiga-amiga was). On PCs it is handled by software, whether firmware (BIOS/EFI) or operating system. Microsoft's official excuse for training people to hit that just to login or unlock a machine is that it's always handled by the OS, which is nearly true (unless a program manages to disconnect the keyboard driver itself), but likely the real reason is that it would make other OSes appear less stable if you happened to hit it on the wrong keyboard.
@TDGalea
@TDGalea 5 жыл бұрын
CTRL + ALT + DEL, ALT + SysRq, etc. are handled at kernel level.
@23bcx
@23bcx 5 жыл бұрын
hey how are PS/2 and usb handled differently b/c I have noticed that PS/2 is slightly more reliable and I thought it had to do with interrupts but this vid kind of points otherwise?
@SebastianScholle
@SebastianScholle 5 жыл бұрын
ps2 is dedicated for inputs. usb is more flexible. so yeah, pro's and con's
@luelou8464
@luelou8464 5 жыл бұрын
USB works by polling the keyboard every few milliseconds. With USB, you can have several different devices connected through a hub, with is very useful, but it means that you can't send data unless it's been requested. A PS/2 device can send a signal and interupt the CPU at any moment.
@lotrbuilders5041
@lotrbuilders5041 5 жыл бұрын
Connor Calarco the Ps/2 can send interrupts and the Usb has to be checked, which is also why you can have a polling rate setting
@AttilaAsztalos
@AttilaAsztalos 5 жыл бұрын
PS/2 is like calling someone you have a message for on the phone. It will ring on their end and they'll hopefully pick it up. USB is like writing a book with one of the pages containing "whoever reads this please take out an ad in a newspaper containing the instructions to copy the message that follows and to mail it as a letter to the recipient mentioned at the end", leaving the book on the shelf of a library and walking away.
@hamditrimech9299
@hamditrimech9299 5 жыл бұрын
I would like to develop a language pack, then add an engine work in the background, which will works like a sentences corrector, all what I found is about how to install a language pack, any idea where to start ? .
@TheThagenesis
@TheThagenesis 5 жыл бұрын
is there still a keyboard interrupt? for PS/2 perhaps but I was under the impression that USB has to be polled constantly for those types of events
@HenryLoenwind
@HenryLoenwind 5 жыл бұрын
Yes and no. The traffic on the cable, that is between SUB controller and USB device, is handled in a polling way. However, the communication between the USB controller and the CPU is not. There the controller sends an interrupt whenever it has data for the cpu. (Or not, there's nothing stopping anyone from making an USB controller that has to be polled, or even using one that can do interrupts with polling software...)
@superfluidity
@superfluidity 5 жыл бұрын
Do applications really need to run code in a loop to pull keyboard events off the queue? I though that when they start up they would just pass the window manager a pointer to a function that will deal with key events, and then when the window manager decides to send them a key event it would wake them up from an idle state and put the execution point at the start of that function.
@Keltheran
@Keltheran 5 жыл бұрын
Short answer: Yes they do. Longer answer: In some languages like Java they have a built in keyboard manager that runs in a separate thread so you as a programmer don't have to do the looping yourself (it is still there though just hidden behind a library) but in lower level languages like C/C++ you will most likely need to do it yourself (It is often also more speed effective since you can decide what keys you need to check and skip the rest and I can't really see any reason why you would use C/C++ unless efficiency is of the essence (like in games or big servers like facebook and google) )
@arsen3783
@arsen3783 5 жыл бұрын
Keltheran not at all true, it highly depends on your library, Qt also shadows handling those events, but some others might not depending on many factors. Also there's reasons to use C(++) outside of efficiency
@0LoneTech
@0LoneTech 5 жыл бұрын
This is an operating system architecture question. Your program could be designed as a set of event handlers, and not actually have a running thread unless it is processing an event, but most operating systems dedicate one or more threads to any process, and one of those threads will then have the task of collecting events. It's essentially a pull architecture instead of push.
@raykent3211
@raykent3211 5 жыл бұрын
Barney Laurance hi. Some languages and op sys's may screw up and restrict the user, but in case it's of interest, the very "primitive" Atmel 8 bit chips don't ( nor do many others, I reckon). The user program can be entirely interrupt driven with the "main loop" simply saying, in effect, "sleep until interrupt". On chip peripherals stay awake but only trigger a response to a state change if the user app has asked for it (setup), the cpu ignores them otherwise. This is significant for micro and pico power apps where polling squanders energy.
@HenryLoenwind
@HenryLoenwind 5 жыл бұрын
It really depends on the operating system, but let's look at this for Windows: Yes. At the lowest level there is an event queue for every program and that program has to pull messages from that queue all the time. Note that that's not a keyboard queue, but a queue for all kinds of events. Keyboard, mouse, window redraw, etc. But virtually nobody codes at that low level anymore. You use some kind of framework to make your job easier, and those all handle that polling and distribute those events to the parts of your code that are interested in them. (And make the difference between the program being 14kB and 14Mb big.) I would have to look it up (it has been over 20 years afterall), but I think Windows has a "sleep while the queue is empty" system call, so your program isn't actually wasting cpu cycles while nothing is happening.
@drskelebone
@drskelebone 5 жыл бұрын
I wondered if there'd be a discussion of debouncing. I guess not, but that's kind of a specialized problem, and not really in scope.
@heta330
@heta330 5 жыл бұрын
what will happen if you press a key and disconnect the keyboard without releasing it?
@Elesario
@Elesario 5 жыл бұрын
Key pressed message, followed by keyboard device disconnected message, and then a pain message from your back as you probably pulled something trying to hold down a key and unplug the keyboard at the same time.
@kaitlyn__L
@kaitlyn__L 5 жыл бұрын
With PS/2 keyboards, it would keep "sending" the character (as in, it would continue to appear in the document). I did this when I was very young. It also made lots of beeps come out of the PC beeper, much like holding keys down on boot. (This is because PS/2 wasn't plug and play, so it also wouldn't be able to tell if you plugged it back in without restarting. So it couldn't just say "oh, the keyboard is gone now", like a USB keyboard can.)
@TheGravyMonster
@TheGravyMonster 5 жыл бұрын
Global mass extinction.
@0LoneTech
@0LoneTech 5 жыл бұрын
This is a little tricky. In layers which observe press/release events only, like many operating systems and programs, the key would appear still held. For a hotpluggable keyboard type like USB, the keyboard removal is a detectable event and should lead to automatic release of all keys that were held there. For a PS/2 keyboard, the key might appear still held but not repeating, as repetition can be done in the keyboard; many operating systems perform repetition in software anyway, and then it might continue to repeat.
@lotrbuilders5041
@lotrbuilders5041 5 жыл бұрын
deltA Emreald on the lowest level, nothing really, on the higher level just an error after disconnect
@ChrisLeeW00
@ChrisLeeW00 5 жыл бұрын
USBHID standard uses interrupts? I was under the impression that they do not use hardware interrupts.
@TDGalea
@TDGalea 5 жыл бұрын
USB doesn't use interrupts; this guy is wrong. USB HID is polled, hence polling rates.
@DonNETRiNO
@DonNETRiNO 5 жыл бұрын
What about IRQs? When we press a key or move the mouse, is it true that the computer does nothing else than processing this input data?
@dandan7884
@dandan7884 5 жыл бұрын
10:25 - are all keys treated equally? - the short answer is: yes; the long answer is: no. "yes" is longer than "no". contradictory statement detected :)
@dzlcrd9519
@dzlcrd9519 5 жыл бұрын
Shanene Larissa Nerdy
@teckyify
@teckyify 5 жыл бұрын
This is wrong on so many levels 🤣🔪
@djhalling
@djhalling 5 жыл бұрын
The long answer is "No. ... It depends where you get up to..."
@rcookie5128
@rcookie5128 5 жыл бұрын
Okay, lemme get this to the next meta level: You _could_ argue that "no" averagely needs more time to be spoken out then "yes", so then the statement would be correct ;) ..okay okay I know where the exit is!!
@TomatoPzoductjon
@TomatoPzoductjon 5 жыл бұрын
well, but "short" is actually longer than "long", so... :))
@DonNETRiNO
@DonNETRiNO 5 жыл бұрын
Mesmerising
@sogerc1
@sogerc1 5 жыл бұрын
xev shows if modifier keys are pressed too.
@joncppl
@joncppl 5 жыл бұрын
Magic SysRq key commands are handled at the kernel level
@kranser
@kranser 5 жыл бұрын
What happens to programs that can accept 'global' key presses when they are not the current window, does the key get sent to the current window first and processed there, and then get polled across any other interested services/programs to see whether those need to process the key too?
@nebuleon
@nebuleon 5 жыл бұрын
Global hotkeys are processed by what Dr. Bagley calls the _window server_ in this video. A user program registers its interest in receiving messages for global hotkeys, and the window server redirects the messages to that program (and possibly to the active window too). That's how your media player grabs the media keys (Play, Pause, Stop, Previous/Next track) regardless of the active window.
@andrybak
@andrybak 5 жыл бұрын
"Are all keys treated equally?" - missed opportunity to talk about Ctrl+Alt+Delete.
@amansharma6377
@amansharma6377 2 жыл бұрын
At what stage do most keyloggers detect keypresses?
@kd1s
@kd1s 5 жыл бұрын
BIOS and polling work too.
@TDGalea
@TDGalea 5 жыл бұрын
"Interrupt". "USB". Pick one.
@AttilaAsztalos
@AttilaAsztalos 5 жыл бұрын
A fancy label for what is actually continuous polling from the USB host.
@martixbg
@martixbg 5 жыл бұрын
Glossing over hardware interrupts... which is really one of the most critical parts of the chain.
@nebuleon
@nebuleon 5 жыл бұрын
It is indeed critical, but not all keyboards will trigger an interrupt, and there are so many ways for the communication to happen. It would have been foolish to focus solely on interrupts when (polled) USB keyboards are so common, and showing more possible communication methods would have taken too long.
@thought2007
@thought2007 5 жыл бұрын
What about ctrl+alt+del?
@silkwesir1444
@silkwesir1444 5 жыл бұрын
You didn't mention the queue (or did i just miss it?) usually, when your program reads a key from the keyboard it'll take it off the queue. you can however also do it in such a way that it stays on there, which in some situations can make sense. however, if the queue is full, all additional keypresses will be ignored until there again is room in the queue. that used to be a huge problem in earlier times, today it almost never is, because the queue is usually much larger plus computers are much faster.
@frankharr9466
@frankharr9466 5 жыл бұрын
I really like, "Short answer: Yes. Long Answer: No". :D
@Robstafarian
@Robstafarian 3 жыл бұрын
"Is life simple?"
@frankharr9466
@frankharr9466 3 жыл бұрын
@@Robstafarian It depends.
@frankharr9466
@frankharr9466 3 жыл бұрын
@@Robstafarian It depends.
@jjput1
@jjput1 2 жыл бұрын
What happens to the program?
@QuasiELVIS
@QuasiELVIS 5 жыл бұрын
You left him hanging by not adding a link where he pointed early in the video.
@smorrow
@smorrow 5 жыл бұрын
He describes the typical event loop at 7:00, but on Plan 9 and Inferno it's just - open your window's equivalent of /dev/tty - by equivalent to /dev/tty we mean it blocks when there's no new input - but we're reading it from a dedicated thread, so it doesn't block the whole program - the thread communicates the keypresses on what Go, as well as Plan 9, calls a channel - no need to invent silly extra things like non-blocking IO.
@DJMavis
@DJMavis 5 жыл бұрын
I am inferring things from the last line. You do seem a bit like a +2 owner
@balping
@balping 5 жыл бұрын
X is not equivalent to a window manager. You can use many different window managers in X
@ximalas
@ximalas 5 жыл бұрын
People running X Window System in one form or another should take the xev program for a spin.
@1e1001
@1e1001 5 жыл бұрын
A key press is a key press, you can't say it's only a half
@what42pizza
@what42pizza 5 жыл бұрын
does anyone else see the cube mac?
@recklessroges
@recklessroges 5 жыл бұрын
10:54 L.E.D. pronounced the french way "lead" is a little ambiguous in English with the verb "to lead" and the 82nd element of the periodic table "Pb" also being a homophone. Obviously context will probably guide a person, but why the unnecessarily ambiguity when we already have lead in our solder for our leds on a PCB to lead electrons to light our way? (Not enough efficiency gain and I'll refer you to Lindybeige on the topic of following the French ;-s )
@xieyuheng
@xieyuheng 5 жыл бұрын
but "yes" is one char longer than "no".
@kranser
@kranser 5 жыл бұрын
What causes the input to be blocked if for example 3 letter keys are pressed simultaneously? Is this Windows or the hardware?
@TDGalea
@TDGalea 5 жыл бұрын
I'd blame hardware before software for the "key overload".
@nebuleon
@nebuleon 5 жыл бұрын
kranser: Multiple inputs on one of the keyboard's "lines" causing ambiguity as to which keys are actually pressed. See the previous video, which discusses the hardware side of keyboards. :)
@lawrencedoliveiro9104
@lawrencedoliveiro9104 5 жыл бұрын
4:05 Another issue is the handling of autorepeat: by having this entirely in software, you don’t actually have to insert the repeated keystrokes into any buffers; you simply generate them on demand, as the user program asks for keystrokes. That way, you never have them happening faster than the program can handle.
@cyancoyote7366
@cyancoyote7366 5 жыл бұрын
An A press is an A press, you can't say it's only a half
@AndrewDiMola
@AndrewDiMola 5 жыл бұрын
A+ Tom and Jerry reference
@alienym0us99
@alienym0us99 5 жыл бұрын
Round 1.... FIGHT 1:08
@Shocker99
@Shocker99 5 жыл бұрын
I think this is rather a vague video. Was that intentional?
@PauloConstantino167
@PauloConstantino167 5 жыл бұрын
This guy always looks like he's about to fall asleep.
@biehdc
@biehdc 5 жыл бұрын
hw > os > inputlib > other input lib > another one > electron/react dont try this in vr, you will vomit
@motorbreath22
@motorbreath22 5 жыл бұрын
Where can I purchase that wig he is wearing, it is fantastic
@arynschroeder4059
@arynschroeder4059 5 жыл бұрын
I THOUGHT THAT THE ONLY WAY A COMPUTER COULD "READ" KEYS WAS THAT EACH KEY WAS A SLIGHTLY DIFFERENT VOLTAGE AND AMPERAGE' SO THAT WHEN YOU PRESSED A KEY ON A KEYBOARD, IT WOULD "READ" THE DIFFERENCES BETWEEN THE KEYS SO THAT IT INTERPRET WHAT KEYS WERE PRESSED.
@asaleminik
@asaleminik 5 жыл бұрын
WHY ARE YOU YELLING
@rory4987
@rory4987 5 жыл бұрын
third
@PandoraMakesGames
@PandoraMakesGames 5 жыл бұрын
All keys are equal, but the keys on a mechanical keyboard are more equal! (I make AI videos)
@Dawwwg
@Dawwwg 5 жыл бұрын
Not all keys are equal, the any key is actually special, with or without a nice mechanical keyboard ;)
@fburton8
@fburton8 5 жыл бұрын
Yeah, some are more equal than others.
@Outfrost
@Outfrost 5 жыл бұрын
This felt like the most awkward video to date on Computerphile. I'm sorry, I love everyone involved in making these, but this particular one was hard to watch and go along with.
@billoddy5637
@billoddy5637 5 жыл бұрын
Mate, Windows all the way!
@doppierobot
@doppierobot 5 жыл бұрын
I can not hear what you are saying. I'm not from England, I usually have no problems understanding english, but you are speaking unclear.
@metalim
@metalim 5 жыл бұрын
So damn chatty... Had to yawn for 5 minutes until he got to the point.
@silkwesir1444
@silkwesir1444 5 жыл бұрын
I used that time to read the comments while listening "with one ear" to what he said.
@kylepls
@kylepls 5 жыл бұрын
This is likely the blandest topic ever covered on this channel.
Mythical Man Month - Computerphile
17:18
Computerphile
Рет қаралды 135 М.
What Happens When I Press a Key? - Computerphile
12:29
Computerphile
Рет қаралды 242 М.
Dapatkan APA PUN YANG ANDA INGINKAN dengan GADGET ini #shorts
00:11
Gigazoom Indonesian
Рет қаралды 13 МЛН
1 класс vs 11 класс (рисунок)
00:37
БЕРТ
Рет қаралды 4,9 МЛН
How AI 'Understands' Images (CLIP) - Computerphile
18:05
Computerphile
Рет қаралды 121 М.
Multithreading Code - Computerphile
15:54
Computerphile
Рет қаралды 376 М.
Twin Proofs for Twin Primes - Numberphile
15:13
Numberphile
Рет қаралды 440 М.
GUI: Under the Hood - Computerphile
17:26
Computerphile
Рет қаралды 153 М.
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 265 М.
Physics of Computer Chips - Computerphile
12:00
Computerphile
Рет қаралды 610 М.
Where GREP Came From - Computerphile
10:07
Computerphile
Рет қаралды 930 М.
Why Does Linus Pirate Windows??
10:30
Linus Tech Tips
Рет қаралды 11 МЛН
How do Smartphone CPUs Work?  ||  Inside the System on a Chip
24:56
Branch Education
Рет қаралды 1,9 МЛН