Reputation: 3
I'm trying to add a button in an IOS app using Swift so that when it's clicked, it executes F1...F12 in a regular keyboard for a Mac or Windows. I look into UIKeyCommand but that doesn't solve the problem.
Upvotes: 0
Views: 373
Reputation: 3
the KeyCodes of the F1, F2 is 0x7A and 0x78. For f3 I did not find
let keyDown = CGEvent(keyboardEventSource: nil, virtualKey: 0x7A, keyDown: true)
let keyUp = CGEvent(keyboardEventSource: nil, virtualKey: 0x7A, keyDown: false)
keyDown?.post(tap: .cghidEventTap)
keyUp?.post(tap: .cghidEventTap)
the same for f2
Upvotes: 0