Each pressing or releasing of the key will be transfered from the keyboard to the computer through the USB cable, so there is no way for the keyboard to send true simultaneous key operations. The keyboard just send messages when a key is pressed or released. The computer will tell the application that two keys are pressed if one "key pressed" message arrives before the "key released" message for the last pressed key.
Как клавиатуры обрабатывают одновременные вводы?
В последнее время я работаю с основными понятиями параллелизма в программировании. Одна мысль, которая пришла мне в голову, была одновременным вводом с клавиатуры. В программировании метод или функция вызывается через прослушиватель событий, который одновременно выполняет только одно нажатие клавиши. Программист должен запрограммировать код определенным образом для одновременного / многократного нажатия клавиш. Мне интересно, как аппаратно обрабатывает «по-настоящему одновременный» ввод. Существует ли какой-то механизм, который автоматически расставляет приоритеты для воспринимаемых входов в определенном порядке?
2 ответа на вопрос
Taking your specific question about keyboard inputs. The computer receives keystrokes along a serial link, therefore the keystrokes are not received simultaneously as they must be - er - serial.
WIthin the keyboard itself is a small processor that reads keypresses and sends them out to the computer on the serial link. Let us consider the case where someone mananges to press two keys 'simultaneously' (whatever that actually means in terms of temporal precision). The keyboard processor is scanning a matrix of digital inputs which give it the keypresses. It will always see one press before another, simply because of its scan across the keys. Even in this scan takes microseconds, one press will be detected before the other.
It is indeed possible that, due to this scanning, the presses may be very close together but the second is seen first.
In the more general field of real-time process controls, it is likely that an interrupt mechanism is employed whereby inputs interrupt a processor to inform it of an event. Again, even if the events cannot be separated in time, one interrupt will get to the processor before the other.
Decently written event-driven software must allow for the fact that two events may be detected very close together and could actually be seen in reverse sequence.
Other sequencing gotchas can be found in cases of I/O processors reporting to a controller computer with a protocol that effectively aggregates inputs.
In summary, can truly simultaneous input be achieved - No.
Похожие вопросы
-
1
Переназначить FN на другой ключ
-
2
Как сопоставить клавиатуру Mac с компоновкой ПК?
-
4
Как переназначить клавишу извлечения на клавиатуре MacBook, чтобы «удалить»?
-
-
10
Есть ли какое-нибудь программное обеспечение, чтобы помочь мне изучить макет Dvorak?
-
6
Беспроводная (алюминиевая) клавиатура Apple на Windows
-
6
Лучшая клавиатура со встроенным указательным устройством для медиацентра Mac?
-
3
Хэш-ключ через Bootcamp на MacBook Pro
-
10
Переназначение клавиши caps lock в Windows или OS X
-
10
Как почистить клавиатуру
-
9
Как отключить или переназначить клавишу «Windows»?