Skip to content

Instantly share code, notes, and snippets.

@cobbal
Forked from bjhomer/keyDown.m
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cobbal/303491c7c87d2ed3364e to your computer and use it in GitHub Desktop.
Save cobbal/303491c7c87d2ed3364e to your computer and use it in GitHub Desktop.
func keyDown(theEvent: NSEvent) {
func intToString(x : Int) -> String {
return String(UnicodeScalar(x))
}
let hasCommand = (theEvent.modifierFlags & .CommandKeyMask).value != 0
switch theEvent.charactersIgnoringModifiers! {
case intToString(NSUpArrowFunctionKey) where hasCommand == true:
// Scroll to top
break
case intToString(NSDownArrowFunctionKey) where hasCommand == true:
// Scroll to bottom
break
case intToString(NSRightArrowFunctionKey) where hasCommand == true:
// Select the current row
break
case " ":
// Scroll down one page
break
default:
super.keyDown(theEvent)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment