old way:
// Check that only Ctrl is pressed
void repeatedly_execute()
{
if (IsKeyPressed(eKeyCtrlLeft)) { ... }
}
// Check that ctrl+A is pressed
void on_key_press(eKeycode keyCode) {
if (keyCode == eKeyCtrlA) { ... }
}
New way
// Check that only Ctrl is pressed :
void on_key_press(eKeycode keyCode, optional int mod) {
if (mod & eKeyModCtrl) { ... }
}
// Check that ctrl+A is pressed
void on_key_press(eKeycode keyCode, optional int mod) {
if (keycode == eKeyA && (mod & eKeyModCtrl)) { ... }
}
See the help article of on_key_press for more details.
void repeatedly_execute()
{
if (IsKeyPressed(eKeyLeftCtrl)) { ... } // make the spaceship go pew pew
}
EDIT : yeah that last use case is definitely still valid for keeping eKeyLeftCtrl... Once again, writing a forum post made me walk myself through the process :-P
=====================
On a side note, I think the article could provide better examples :
//This checks if Ctrl was pressed :
if (mod & eKeyModCtrl)
It could do with an example showing Ctrl+A instead of just Ctrl. I'm guessing most scripters are after that.
It could also do with an example of Ctrl+Alt+A as it is where the modifiers and the binary logic will shine