How to detect external keyboard connectification in objective-c? - objective-c

My application need to know are external keyboard connect or no. How could i do to know that? No Private API please. :)

If this is iOS related, I'm not sure why you'd want to detect this as the hardware keyboard acts exactly the same as the software keyboard (except with a few extra shortcuts for sound, brightness etc. which your app shouldn't use anyway).
If you're considering screen space, then the software keyboard will still send it's notifications when it is displayed or when it is hidden, so you can respond to those. For example, say you have the software keyboard up and then you connect your external keyboard. The software keyboard will hide, and will post the UIKeyboardWillHideNotification. So you can respond to that.

Related

KeyCode for Android Keyboard Microphone

I have been looking for a way to manipulate the microphone on the keyboard of an Android. Currently I have a button that brings up the google Text to speech. It works fine. However I am debating on the functionality portion.
I wanted to the option a user can tap the button which works flawlessly. Then the option of tapping the mic on the keyboard. I figured that if speech was in place the mic would be used for the keyboard as well. However in my case it doesn’t work.
My question is can I simulate the keyboard microphone function. The answer is there is always an away. Then again since it’s not working by default do I have to set the function for the mic portion.
I am assuming that if I do it would be the same code code has the button mic I created in the design. I have looked for key codes and found numerous key codes for remotes and such. There is no microphone on there just
media-record
So is media record the keycode for the keyboard mic? All I am needing is the keycode for the mic nothing else. Also my main concern is that is the mic on the keyboard coded to standard. Which means custom keyboards and what not.
I am not sure what to do here, if there is a keycode I can manipulate or if it’s just developed by default only.
I think it would be easier to just hit the mic on the keyboard to talk and let google speech do it its thing, rather than tap off the keyboard and press my custom button to record.
Does anyone know the keycode that would allow me to manipulate the button. I don’t the how to do it, I just need to access the keycode. As I said I have several lists that has keycodes for the complete android phone, however none of the media codes works With default keyboard mic.
Any help would be appreciated.

Is Desktop Mode Accessible When Using Bluetooth Keyboards in ChromeOs v69?

I just found a great bluetooth keyboard by Brydge for the Pixel Slate and am wondering if current ChromeOs devices can manually transfer from "tablet" to "desktop" mode when you attach a bluetooth keyboard?
It seems like this is feasible by enabling a setting in developer mode. Thanks to #Skawtnyc's response on Reddit!
You can switch back and forth on the fly. Enable chrome://flags/#ash-debug-shortcuts and then you can use CTRL+SHIFT+ALT+T to switch back and forth between desktop and tablet mode.
If you connect a mouse it will automatically switch to desktop mode, but using this method you can still switch back and forth.
#Skawtnyc also points out a bug to watch out for when using an external display such as a monitor.
Keep in mind that when connected to a dock with an external display, this setup can trigger a crash/restart error. The cause is the virtual keyboard. Anything that causes the virtual keyboard to appear on screen will trigger it. The workaround is to go into Accessibility settings and turn off the on-screen keyboard. You don't need it anyway when using a physical keyboard.

Programmatically disable all Notification Center banners on Mac

Can a Mac app temporarily disable Notification Center, for example while it is doing a full-screen presentation? Apple says alerts are "automatically disabled while you’re presenting in Keynote. They also won’t appear if your display is mirrored on an external monitor." Do third-party apps also have the ability to temporary disable notifications?
I don't think so, but my assumptions are base on iOS, where you can't turn off notification center at all.
You can enable Focus (aka Do Not Disturb) which will hide current notifications and prevent new ones from popping up. See https://support.apple.com/guide/mac-help/turn-a-focus-on-or-off-mchl999b7c1a/mac for how to enable/disable it.
I do not know if applications themselves have control over enabling/disabling Focus.
I use the Touch Bar and add the Focus button to quickly enable it if I need to present or share screen. I do not see a keyboard shortcut you can set in Monterrey like you could in Big Sur.

Polling the keyboard in Cocoa

My Cocoa application should react continuously to the state of the keys pressed by the user. To that end, I would like to poll the keyboard at fixed intervals, instead of relying on keyboard events. Is there any Cocoa API to achieve this? If not, what other options exist?
Polling is never such a great idea. You shouldn't have to do that in most cases.
There is 2 API you may be interested for:
Quartz Event Taps https://developer.apple.com/library/mac/#documentation/Carbon/Reference/QuartzEventServicesRef/Reference/reference.html
IOKit HID API https://developer.apple.com/library/mac/#documentation/DeviceDrivers/Conceptual/HID/intro/intro.html#//apple_ref/doc/uid/TP40000970
Please note keyboard accesses may pose some security issues so the system may not allow you to read the keyboard state. Check the Accessibility settings (access to assistive devices).
Don't poll the keyboard, just implement -keydown: in your App delegate class.

How do I Capture keyboard/mouse events with my application in focus?

I'm building a synergy like app for Mac OS, that captures keyboard/mouse and sends them to a remote computer.
I wish to capture all user keyboard and mouse events, while my NSWindow is in focus (if possible, while not in focus would be nicer). the catch is - I don't want system shortcuts like CMD+Tab or CMD+Q to interrupt me, I wish to handle them before the windowing system does, so that my app won't loose focus. Same for mouse.
Thanks
Check this - Cocoa Event-Handling Guide
Hope this helps :)