Excel-DNA - Shortcut Ctrl + Letter - excel-dna

In my XLL, I would like to have my command be assigned the shortcut Ctrl + U.
With the following code, I was able to assign Ctrl + Shift + U. Is there a way to only assign Ctrl + a letter.
[ExcelCommand(ShortCut = "^U")]
public static void CtrlU()
{ //Code
}
Thanks,
Guillaume

This worked for me:
[ExcelCommand(ShortCut = "^u")]
public static void DoBeep() => Console.Beep(400, 500);

Thanks Govert. I had my letter in Uppercase, that's why I had to use Ctrl + Shift + U. When I put my letter in lowercase, it works.

Related

Why is this functionKey selected when I press F1, F2, etc?

I am reading the keyboard shortcuts typed inside a NSTextField.
When I press, for example, shift + option + F2, this method
class func convertToString(event:NSEvent) -> String {
var shortcut = ""
let intersection = event.modifierFlags.intersection(.deviceIndependentFlagsMask)
if intersection.contains(.control) {
shortcut.append("^ ")
}
if intersection.contains(.option) {
shortcut.append("⌥ ")
}
if intersection.contains(.command) {
shortcut.append("⌘ ")
}
if intersection.contains(.shift) {
shortcut.append("⇧ ")
}
if intersection.contains(.function) {
shortcut.append("fn ")
}
let character = keysCodesToCharacters[event.keyCode]!
shortcut.append(character)
return shortcut
}
will evaluate true for
if intersection.contains(.function)
In theory this tests for the function key but the most strange part is that event.keycode comes as 120 that corresponds to F2.
So I don't need to do this test at all to test for the function keys F1 to F12.
The big question is: what is the purpose of this .function. What is this testing?
I thought of the fn keys on the mac keyboard but these keys are not detectable and when I press any key from F1 to F12, this method gives me the keycode of the key plus this function true.
What I mean is this: when I press F2, for example, I receive event.keycode, meaning that F2 was pressed and also functionKey (63) as true? Why the redundancy?
Apple's documentation isn't what is used to be.
If the documentation doesn't help, check the header. Copied from NSEvents.h:
NSEventModifierFlagFunction = 1 << 23, // Set if any function key is pressed.
NSEventModifierFlagFunction was NSFunctionKeyMask, documentation:
NSFunctionKeyMask
Set if any function key is pressed. The function keys include the F keys at the top of most keyboards (F1, F2, and so on) and the navigation keys in the center of most keyboards (Help, Forward Delete, Home, End, Page Up, Page Down, and the arrow keys).
Apparently the .function flag is also set when the fn-key is pressed (on my Apple keyboard, my Logitech keyboard handles the fn-key internally).

OSX + PhpStorm: Disable non-breaking spaces

How can I remove the non-breaking spaces that appear when I click Shift + Alt + Space? They are really annoying when writing code since they produce errors.
I have tried adding the following to DefaultKeyBinding.dict:
{
"~ " = ("insertText:", " ");
}
I would like it to work in both Coda + PhpStorm. Thanks!

XCode changing default behaviour of comment shortcuts

Is there a way to customise XCode comment actions. Example:
original
func thisfunc() {
var x = 5
}
when commented (cmd + /)
func thisfunc() {
// var x = 5
}
not
func thisfunc() {
// var x = 5
}
In the default behaviour XCode puts the comment in the beginning of the line but I want it to be like the first commented example (like sublime text comment blocks).
I don't think you can customize XCode the way you want. However there's still a way to do it by the steps are (1) selecting commented code (2) cmd + [ (3) cmd + / (4) ctrl + i. Have a try and this is not that complicated.

How to convert a selection to lowercase or uppercase in Sublime Text

I have several strings selected in a file in Sublime Text and I want to convert them all to lowercase.
How can I convert them all to lowercase in Sublime Text?
From the Sublime Text docs for Windows/Linux:
Keypress Command
Ctrl + K, Ctrl + U Transform to Uppercase
Ctrl + K, Ctrl + L Transform to Lowercase
and for Mac:
Keypress Command
cmd + KU Transform to Uppercase
cmd + KL Transform to Lowercase
Also note that Ctrl + Shift + p in Windows (⌘ + Shift + p in a Mac) brings up the Command Palette where you can search for these and other commands. It looks like this:
For Windows:
Ctrl+K,Ctrl+U for UPPERCASE.
Ctrl+K,Ctrl+L for lowercase.
Method 1 (Two keys pressed at a time)
Press Ctrl and hold.
Now press K, release K while holding Ctrl. (Do not release the Ctrl key)
Immediately, press U (for uppercase) OR L (for lowercase) with Ctrl still being pressed, then release all pressed keys.
Method 2 (3 keys pressed at a time)
Press Ctrl and hold.
Now press K.
Without releasing Ctrl and K, immediately press U (for uppercase) OR L (for lowercase) and release all pressed keys.
Please note: If you press and hold Ctrl+K for more than two seconds it will start deleting text so try to be quick with it.
I use the above shortcuts, and they work on my Windows system.
As a bonus for setting up a Title Case shortcut key Ctrl+kt (while holding Ctrl, press k and t), go to Preferences --> Keybindings-User
If you have a blank file open and close with the square brackets:
[ { "keys": ["ctrl+k", "ctrl+t"], "command": "title_case" } ]
Otherwise if you already have stuff in there, just make sure if it comes after another command to prepend a comma "," and add:
{ "keys": ["ctrl+k", "ctrl+t"], "command": "title_case" }
For Windows OS
For Uppercase
CTRL + K + U
For Lowercase
CTRL + K + L
For others needing a key binding:
{ "keys": ["ctrl+="], "command": "upper_case" },
{ "keys": ["ctrl+-"], "command": "lower_case" }

How to handle keyboard short cuts ( shortcuts like Command + control )?

How can I get the keyCode for a particular combination in KeyDown? What would be the keyCode for Control + Option + A. or Command + Control +Shift +X?
[NSEvent modifierFlags] will return a bitmask of the modifier keys that are currently down (http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/ApplicationKit/Classes/NSEvent_Class/Reference/Reference.html)

Resources