Detect if ctrl key is pressed
Per your latest comment, you state that the code you have quoted works in practice, and your only problem is you want to get rid of the deprecated NSControlKeyMask.

Simply replace that word with NSEventModifierFlagControl and this is it.

The only thing Apple did is to change the name. In recent macOS NSControlKeyMask is even defined as simply being equal to NSEventModifierFlagControl. Both have the value 1 &lt;&lt; 18 (i.e. the 18th bit is set to 1, rest is 0).