Events

We all use keyboards in our everyday work life. We use them to write code and compose e-mails. There is no knowing when a certain key will be pressed. However, when a key is pressed, the user expects certain action to happen—for example, the letter indicated by the key should appear in the editor when we are writing code.

This seems natural enough, doesn't it? However, note that there is an elaborate mechanism at work here. The operating system piece needs to know which key was pressed. So, one way to find this out is to go and ask periodically whether any key was pressed, and if so, which one. This is called "polling" for any interesting information. When we poll, we go and ask the driver, at intervals about any status regarding whether ...

Get Scala Functional Programming Patterns now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.