28.5. The keyboard
Let’s talk about how we handle the keys in the Pop Framework. In order to process keys, your CView can either have an OnChar handler or an OnKeyDown handler. But it turns out, the OnChar handler is only good for letter keys. So in order to process arrow keys we use VisualStudio to add to CPopView the OnKeyDown handler for the WM_KEYDOWN message.
When you press a key, the view that has the focus receives an OnKeyDown message. If you continue holding the key down, the focus view will continue receiving OnKeyDown messages (but it won’t necessarily get repeated OnChar messages). The timing between these messages varies greatly from machine to machine, and you should never write code that depends on any assumptions about how often ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access