Keys pressed - Swift - swift

I am trying to run some code when the user presses the space bar, does anyone know how to do this? Key codes would be helpful. I am programming in Swift an using SpriteKit

Well using google you can search for lists or images of keyboards with the listed keycodes, however I suggest using problem solving for when something like that isn't available. When the keyPress event is called, print the keycode that was pressed. This way, you can press the space bar and it will tell you what the keycode of it was without having to rely on outside sources.

Related

KeyPressFcn in Matlabs App Designer

Hey there great ppl out there!
I have a rather simple problem but no idea how to solve it. 2h Google search didn´t help.
I´m getting hands on Matlab´s App Designer.
To keep it simple: I have a button and a numerical field. Every time I click the button - a callback is called increasing the value of the numerical field by 1.
How can I implement a KeyPress event?!? I.e. When I press the '+' Key on my keyboard I would like to trigger the callback fuction of the button (or if not possible any other function).
I´m pretty sure the developers of App Designer must have thought about this - but I´m simply to untalented to find the right documentation. I think in GUIDE there´s something called 'keypressfcn' - so I basically need an equivalent for the App Designer.
Please help :)
Increasing the Number field by 1 when hitting the button or pressing the '+' key on my keyboard
A KeyPressFcn has been added as of Matlab R2019a. In appdesigner click the Callback button, select your figure, then choose the callback 'KeyPress'. I got it to work. More info here: https://www.mathworks.com/help/matlab/ref/matlab.ui.figureappd-properties.html

How to read keyboard state in Swift / MacOS?

I'm writing a game in Swift 3 for Mac OS. I'd like to be able to do "as long as the A key is down, move to the left". In other environments I'm used to a function like KeyIsDown('A'), but I can't find it here.
Does it exist, or do I need to watch every keydown and keyup event and keep track of the state myself? I will be wanting to do this for arrow keys as well as alphabetic keys.
Kudos to BallpointPen, for a clear answer. So I'll just keep a table of key state for every keycode, and switch bits on an off as keyDown and keyUp events come in.
Depending on you use UITextview or UITextfield. So, conforming UITextviewDegelate or UITextfieldDegalate there are some degelate methods that can change keyboard state.

Property additionalActions of NSUserNotification seems not working?

To understand NSUserNotification better, I wrote a little test app playing with this class.
So far so good, except that no matter how hard I tried to feed the additionalActions property with array of NSUserNotificationAction objects, it never showed any difference but only one action button and a close one.
My expectation for this property is that the notification would show a pull-down menu containing the additional buttons I offer as it does in the Mac App Store update notifications.
Am I missing something? Or are you having the same problem, since it is a bug awaiting Apple to tackle?
Can you please try to click and hold down the action button in your notification? Does it show a drop-down menu of additionalActions?
Update
As it turns out, you can show the little chevron next to the action button by setting a true value for the private _alwaysShowAlternateActionMenu key on the notification. In Swift 3, it would look like this:
notification.setValue(true, forKey: "_alwaysShowAlternateActionMenu")
However, as I mentioned this is a private API and I strongly advise against using it if you want to distribute your App through the Mac App Store.
It is probably a bug. Setting up additionalActions will create the list, but not the little arrow icon. Holding down on actionButton will show the menu with the number of actions you set.
Besides setting additionalActions will cause several other problems. I will save this for another question.
Refer to another question.
show NSUserNotification additionalActions on click
P.S. I am using El Capitan APIs

are there DOM events for controller presses on the PS3?

I want to develop a site which is easy to use from a Playstation 3 PS3 game console web browser. I thought it would be good to make screen actions on button presses on the console.
I can find no information on how to do this after quite a bit of searching.
Any info or links highly appreciated!
Why not write a function that displays a message for every "keystroke" and you'll see what values they represent:
$(document).keypress(function(event) {
alert(event.which);
});
Then you can use the number you get from this test and create some logic based on that.
Like this perhaps:
if(event.which == 13) {
// display cool menu maybe?
}
From what I've tested so far, the left stick generates mouse events, left pad with arrows generates keyboard events corresponding to arrows, while the right stick generates a mouseevent but unfortunately it does not move the mouse, but rather scrolls the window.
I do not know how to detect in which direction the stick is pushed (unless the cursor actually moved or the background scrolled, in which cases it is quite trivial).
Check: http://vanisoft.pl/~lopuszanski/public/ps3/

iPhone/iPad keyboard shortcuts?

There's an action in my program which users need to perform very frequently (potentially hundreds of times per session), and I'd like to add a keyboard shortcut for users with a bluetooth keyboard. Is there any way to do this?
Right now, the closest I've come is triggering the action whenever the U+F8FF character is entered (Shift+Alt+k on an iPad/iPhone/Mac, which prints an apple logo character) in a text view. Of course, this would present an issue if the user actually wanted to input an apple symbol.
Are there any better ways to support keyboard shortcuts (hopefully Cmd+something, rather than Shift+Alt+something)? Thanks!
Under Cocoa for Mac OS X, you would gather modifier key information from the NSEvent passed to the keyDown: method in an NSResponder object. CocoaTouch replaces the NSResponder with UIResponder and NSEvent with UIEvent. The UI versions don't have documented keyboard event support. I'm guessing that Apple has extended UIResponder to handle keydown events, but hasn't publicly documented the changes yet. Unfortunately that means we'll just have to wait for that documentation to be able to read the modifier keys.
I think your current solution is a fine solution until Apple gives us a keyboard supporting UIResponder.