My programming background comes from C and some C++ programming with strong emphasis on C# at the last years.
I am very new to Cocoa and ObjectiveC programming (not to mention Mac stuff) and I am developing an iPad application.
I would like to get keyboard codes from the standard on-screen keyboard but without using any (at least visible) control like Text Field. Also, I would like to get the key codes as soon you press it, detecting both the key down and up events.
Any hints on how that is doable?
Thank you in advance
Pedro Duarte
[EDIT]
After seeing the key down and key up ideas within your question now!!!
The only ways I know how to capture press down, and press up events are with gestureRecognizer objects, or with writing your own custom code within
and
Problem is there is no way you can over-ride the natural keyboard touch event structure with your own to be able to capture up and down events separately. This gets to the real sad part. In order to do this, you will most likely have to create your own keyboard, as well as event structure using the routines I stated above as even gestureRecognizer objects aren’t granular enough to give you the down and up events separately.
[ORIGINAL]
The way to do this is to put an invisible UITextField on screen, when you wish to have keyboard input.
You would then implement some or all of the UITextField delegate methods to grab your text at the end of editing , during, etc…
Here are a couple of SO links to get you started as well!
// The below implements a custom keyboard capability that limits text input to floating point numerics (not scientific or anything, just simple floats with a single period) and is re-putting the text back onto the visible UITextField that initiated the input.
Need a robust solution to keyboard entry of an integer value in Settings bundle
With the below, a UITextField is created dynamically in code when a user taps on an element of a UISegmentedControl (as they wish to change the text within the one pressed). The UITextField is made invisible, and the text is applied to the text of a UISegmentedControl Item.
Change title of segmented control with edit button?
One doesnt have to implement it this way. You could statically define your UITextField, make it invisible (on screen), and only activate the keyboard for it when the object you wish to have its text changed is tapped, etc…