faster way to type lambda symbol - visual-studio

sounds a bit silly and petty to ask, and ironically I am sure that by typing out this SO question I have actually lost more time than I could potentially gain :)
but something I was just wondering if other visual studio guys have solved this scenario
when writing out a lot of lambda function (especially when doing a fluent config) it just feels very inefficient to type out a lambda, the equals character is on the top number row of the keyboard, and the greater than sign is all he way on the down by the spacebar, and it requires using the shift at the seem time.
just feels cumbersome,
just wondering if someone knows how to build a macro or shortcut. I would much rather double tap a key or something like that. it would allow for much faster typing
(note: i am using both VS 2010 and 2012)

There are a couple of options
A. Can use autohotey to send a key when you press another 'hot key' or registry remap
http://www.autohotkey.com/docs/misc/Remap.htm This is a one to one re map
B. use auto hot key to send the key when you press Windows + Other Key like M to send the key you want http://www.autohotkey.com/docs/Hotstrings.htm
C. write a low level keyboard hook ( I know it is possible but do not know c nor have the device driver kit to try)

One solution is to use AutoHotKey to set up your own key combo or character replacement.
Check out the documentation to find something you're comfortable with, but here's the basic formula. This one will => on the combo Windows + . (since > is the uppercase of .)
#.::
SendInput {=}{>}
return
or
#.::
SendInput {Space}{=}{>}{Space}
return
if you'd like it to automatically space before and after the lambda

Related

Keyboard layout (OS X) - write a sentence with one character

I am a web developer and use git and other small commands all the time in terminal. I know git goodies, how to use aliases, etc., but I was wondering whether it is possible to do it with keyboard layouts?
(1. Just for fun, 2. There might be other uses of it)
I managed to create keylayout file and substitute a character by a word, but I cannot get further than 20 (or so) characters. Does somebody know whether there is some limit on it? I played with maxout variable but it had no effect.
I hope I was clear on my question, might be a bit abstract. https://developer.apple.com/library/content/technotes/tn2056/_index.html
Thanks in advance!
Not sure if you ended up figuring this out, but I'm right there with you—couldn't figure out a solution, trying to input 30 or so keys seems to crash whatever application is open, and relaunch Finder. Bit of a shame, although you could try using text replacement? It's under System Preferences > Keyboard > Text, I've been using that for misc things that I was too lazy to slap on my keyboard.
Key replacement doesn't seem to have a limit, although it might and I just didn't notice. Bit of a bummer, seeing as I'd prefer to hit "Alt-B" instead of typing something like :replaceme:, but it seems to get the job done. Doing some quick testing revealed no problems outputting 2,000 chars via text replacement, although after that it seems to hit some sort of limit (2048, maybe). For now, though, this seems to be the best solution.

Meta key does not work

I'm trying M-w (command -w) on my mac Air, but get requests to terminate my terminal process.Then I found on internet that on some computer it uses option. I tried that but still not working.I'm trying to copy file.
If you're using the Terminal, there is an option under Terminal Settings > Keyboard to "Use Option As Meta key". Select that and you'll be able to use the option key for things like M-w. Personally, I find that I want to have both CTRL and META on both sides of the keyboard, so I map the "command" key to be "control" and "control" to be "command" using the System Preferences Keyboard pane, leaving the "option" key to be a "Meta" on both sides of the spacebar. This allows me to work fluidly without having to strike two keys with one hand, which saves me a lot of ergonomic distress.
Some people like to use the caps lock as a control key, which has the advantage of increased ease of access to the control key on the left side, but it has three major disadvantages in my view. First, it gives an asymmetry, which I find reduces fluidity of typing. Second, it costs you a caps lock key, which I use for example when I have to type out a named constant (rather than holding down a shift key to type out something like SELECTION_CATEGORY_RESTRICTION_ELEMENT, which I would prefer to be able to touch-type). Third, it tends to encourage the use of certain left-hand key chords, which in my experience has led to extremely painful repetitive strain injuries.
Because of the latter, in particular, I do not recommend remapping the caps lock key to CTRL, but your mileage may vary.

Keystroke in AppleScript maps numbers to those on keypad, which cause some problems

I need to send some keys to another program, and I tried keystroke in AppleScript. Everything worked well until I found that when I sent numbers to a Windows program running in Parallels virtual machine, it didn't work, but instead, it change the position of cursor.
Then I use program keyboardSee to find what's wrong, and I found that all numbers and some symbols are mapped to the keys on numeric keypad, not the numeric line. So maybe the NumLock is off in the virtual machine, and the keys mapped to keypad trigger not numeric but control keys.
I found some people says that use key code can solve this problem, but I cannot find a perfect char-to-keycode table, and I also notice that people said key code could be different for the same character in different keyboard layout.
So how can I solve this problem perfectly, means how can I make it always map numbers to numeric line, and perform the same in no matter what keyboard layout?
I'm afraid to say that I don't think this is possible at the moment. In general, Mac apps know that macs don't even have the same characters on their Numberpads that PCs do (no arrows, no num lock, etc), so the distinction is meaningless. Some poorly ported Mac apps do make a distinction though, such as World of Warcraft (although it isn't the worst port out there by any means). I believe parallels has a num lock in its menus somewhere (if I recall correctly), so you should be able to get around it that way.

What would it take to add new modifier keys to Windows?

From what I can tell, the notion of "Shift", "Alt", and "Control" are pretty well hard coded from the keyboard itself right through the OS APIs. Sometimes I see the Windows key used as a modifier, but it doesn't seem to register as a "real" modifier key, any more than any key on the keyboard would.
But could a person add a new modifier key? Maybe in a wild and insane effort to bring back the space cadet keyboard? Aside from a physically modified keyboard (or maybe just remapping some unused keys), what else would it take? New drivers? New APIs calls? A complete rewrite of the OS?
I guess this kind of thing would be a lot easier to do on an open source OS than on Windows as well, yes?
Well, there's benefit in having a standard for keyboards and mice. It makes things "work" without needing special drivers or operating system patches. But that implies that keyboards and mice have to be standardized themselves in order to have them "just work".
So, if you wanted to add an extra key to the keyboard - whether it is a modifier key or not - you have to somehow make it useful which means that applications need to be aware of it and they need a way to be notified of this key's state. Fortunately, Windows and other operating systems Open Source or not, provide an extensible and also standard mechanism for this: drivers.
So, in short you would need to provide a driver to extend the standard functionality of the standard keyboard much like you would need a driver if you bought one of those fancy mice that come with 19 special buttons and 3 scroll wheels instead of the standard two-or-three buttons and one scroll wheel.
And finally, you would need applications that are aware of your special keyboard. What use would it be to have this modded-keyboard after all if you application were ignorant of it's superpowers? The only thing you'd be able to do with your special keyboard would be to create hot-keys that incorporate your special modifier..
I am curious about your reason. Do you actually wish to utilize and fully integrate the use of an additional modifier key in your daily computer usage? If so, in what way? (This is pure curiosity on my part; I'm fascinated by the reasons or events leading up to your query! And I will explain why.)
Let me first state that I can not fully answer the question you asked (what exactly would be involved with adding a modifier to the OS) other than to say that it would take much more work than what I believe any individual could accomplish—even within several years (except for some true computer genius); but depending on your reasons for asking, I can show you that it probably wouldn't be required for your purposes (although that's obviously speculation). And actually, technically, more modifiers actually exist but they are virtually undocumented and very rarely used.
I have had been toying with this question for quite a while now. My first meaningful introduction to using personal computers was with a Mac during their early years. Macs have always had at least two, genuine "character" modifier keys; as well as two "command" modifier keys. I think this distinction is an important one, although it is not typically, explicitly explained or mentioned. In the modern era Macs can functionally have up to 5 modifier keys; although there are some limitations on how they may be effectively utilized for various purposes. *nix OSes can support a whopping 8 modifiers, I believe. However, making use of them with a modern keyboard would require some remapping.
However, most of my personal computers have been Windows based, and when it comes down to it, Windows really only seems to support 1 true character modifier key: Shift. This is an absolutely unacceptable state of affairs for me! Why? I need to type WAY more characters than that!
Why? Because I have a strong interest and background in foreign languages, linguistics, phonetics and writing systems. I need to be able to type (without excessive difficult) many more characters and symbols than Windows seems to support. This is mostly for fun though, so it hasn't been crucially urgent. And I've been able to gain access to a Mac when I need to create/edit documents containing virtually any language besides English.
So, in Windows the Alt key is internally referred to as the Menu Key because it was initially used to access and navigate the command menus of applications in the days before Windows had adopted the use of a mouse. And it still functions in this capacity. Technically, it can only function as a modifier key if used in conjunction with Control. ISO Keyboards (European/foreign keyboards) often have a key called AltGr instead of the "right side" Alt key; it stands for Alternate Graphics and it is used to map the additional symbols and accented letters required by other languages to a "regular" keyboard by making accessible another whole layer or two of the whole keyboard, which effectively doubles (or even triples or quadruples) the number of characters that can be typed. Technically, the AltGr key is merely the one key which triggers the Alt and Control key simultaneously for the convenience of typists fingers.
You don't actually need an ISO keyboard in order to use AltGr and to access those additional characters; however, they make it much easier since they generally have have a the characters each key can produce printed on the key itself, like we do. All you really need to do is activate a keyboard layout for one of those languages (which are built into all versions of Windows). And you'll probably need to print out a diagram of the keyboard you choose to use. Or make stickers to put on your keyboard until you learn how to type all the symbols you need.
By the way, the Windows key IS a fully fledged modifier key, but its use is restricted for Microsoft to delegate as they see fit. (Actually, they designated that combinations using numbers as "free game" for OEMs to specify on their systems). It is designed as a modifier key on the hardware level.
The technology which supports most keyboards generally works just fine for standard usage of the keyboard (which typically does not include gaming) for typing, inputting text/data, research and so on. But, in order to safe costs and simplify they are designed so that the keys to be used as modifiers can be pressed together and recognized, along with at least one or two other keys. However, you quickly run into problems if you try to move modifiers to other keys on the keyboard and still hope to trigger "chorded" hotkeys (2, 3 or more keys pressed at once) because those keys weren't designed and given the hardware to function as modifier keys. The Windows key—even though it isn't used in that way in Windows (so far); it has the technical requirements.
Furthermore, Windows keyboards can be plugged into a Mac and and will work just fine. The Windows key corresponds to the Apple Command key; which is used extensively by most apps for triggering complex hotkeys/keyboard shortcuts— and it does this without issue.
So, despite the claims in another response; it is actually much easier to "add an extra key"- or several to your keyboard. Without the need for custom drivers, or even anything but the built-in OS driver. All you need to do is designate the key as one of the handful of additional keys found (and recognized natively by Windows) on various foreign keyboards.
There are three prominent keyboard types: ANSI (American), ISO (European) and JIS (Japanese); another common variant is the Brazilian keyboard; generally referred to as Abnt (which actually refers to the underlying "name" of the extra keys found on those keyboards: VK_ABNT_C1 and C2).
Technically, there are one or two unique keys found on ISO keyboards (known as VK_OEM_8, and VK_OEM_102). And Japanese keyboards can have more than 8 additional keys; however, they typically have 5-6 additional keys two of which are special keys used in the various methods of translating the few dozen key presses on a keyboard into one of several thousand complex ideograms. The other is a MODIFIER key! Korean keyboards feature it as well. It works like CapsLock, but instead of switching to upper case, it switches to the Korean alphabet or the Japanese syllabaries (because all computers still require a keyboard capable of typing Latin for passwords, etc. as far as I know). But it becomes very tedious and frustrating for users who switch writing systems constantly to have to switch the keyboard layout back and forth. So, they solved the problem with a locking modifier key that often has an LED light, just like CapsLock, to provide simple, instant visual cues as to which writing system will be produced.
Another type of Japanese keyboard was developed especially for ease and speed of typing. Although it never really took off (there were lots of different ideas and models in the 80s & 90s before anything was standardized), this keyboard by Fujitsu remains popular and a favorite for writers and anyone who much produce large amounts of text in Japanese.
Its special quality is that it has 3 large key which replace the space bar, only the smaller center key produces spaces, the other two are "thumb modifier keys" which are very convenient to use without finger acrobatics; they can even be combined with shift fairly comfortably and thus provide an extra large inventory of physically type-able characters. Technically they two modifiers are supported by Windows as well! Although, the support is scant and documentation virtually non-existent (at least outside of Japan).
However, it is still possible to make use of these keys in various ways if you remap and re-purpose a few keys on your keyboard- especially if you have a full keyboard with a number pad.
It's actually possible in Windows to have as many as 15 layers on your keyboard (including the base level) each of which must be activated by a unique combination of modifier keys. Actually, there are something like 48 possible (valid) combinations with: shift, control, Alt-Control, kana, loya and roya; so can't use anywhere near the theoretical possibility.
I've been using a special keyboard layout I developed that uses all those keys and has 15 layers which allow me to easily compose text in any language using the Latin alphabet (including any accented or modified letters), as well as the International Phonetic Alphabet (IPA) which is used to precisely document in written form any language or dialect on Earth. I also several layers dedicated to typing Ethiopic (I lived there as a kid); plus I have layers for rudimentary Greek, Hebrew and Arabic as well as a layer for symbols. Additionally, I have lots of deadkeys programmed into my keyboard—which are ideal for accented letters (first you press the key for a particular accent marking, but nothing happens until the next (or sometimes 3-5 keys) are pressed (if the deadkeys are "chained" to add several marks to a single letter, like Vietnamese does to an extreme degree); when the actual letter is typed it will have all those accents or marks stacked up/applied if possible.
What YOU need to make this possible?
A little piece of software called KbdEdit (the Premium version) which is VERY reasonably priced (IMHO).
There is a trial version you can check out for free of course; the website is PACKED with useful, fascinating and often obscure information on keyboards.
Other (free) software which allows you to do all sorts of things, including making use of all the modifier keys MUCH more freely for virtually any purpose is available as well. It is called AutoHotKey. I have been using it for years to do all sorts of nifty things (it's actually part of my system for remapping my keyboard for 3 additional modifier keys (it lets me "double use" keys so I don't lose functionality. For instance, I have physically remapped the two Japanese thumb modifiers to my Alt keys. I never use the Alt keys to access the menus in windows apps; however, I use software that does make use of keyboard shortcuts that contain Alt. However, as you may recall, Alt must always be used with Control to do anything other than navigate the menu. So, I didn't use any combinations of Control with the thumb modifiers on my custom keyboard layout (which posed no challenges). And I have AutoHotKey configured to convert simultaneous pressing of control and either thumb modifier to "control-alt" and if I happen to need just Alt by itself, pressing Windows+either thumb modifier is translated to Alt (since I've never encountered any shortcuts that required both Windows and Alt that created no conflicts.
I also DESPISE the trackpad on my laptop; trying to use to scroll is erratic and infuriating; furthermore, it is incapable of producing a middle click which I use extensively. So, I re-purposed that key that nobody uses that opens the "context menu" (because it's much easier just to "right click" to open that menu), usually called the "Application Key". If I'm holding it down (like a custom modifier), it translates arrow-key presses into scroll-wheel movement (in up-down or left-right axes), and it converts a space bar tap to a middle click. I also have some function or button programmed to be triggered by all of the other keys I can easily reach with that hand while holding that "faux" custom modifier. I'm able to control my media apps by simulating media keys that my little laptop doesn't have, and a host of other cool things.
AutoHotKey would probably be able to accommodate for most any reason you would want to add an additional modifier key to your keyboard, without actually going through all that rigmarole!
Windows W32 API defined Virtual-Key Codes. It is 8-bit, it provides 256 values and there is some gaps in table.
WM_KEYDOWN message operates on these codes.
Modern keyboards allow to detect up to 6 simultaneous key press but there are N-Key Rollover and Key Ghosting problems that you should be aware.
.Net API expose only Alt/Shift/Control as modifier.
In nutshell - many core APIs provided by Microsoft relay on Alt/Shift/Control as modifier even if modern keyboards allow near 5 simultaneous modifiers in addition to key press.
I don't know specifically about modifier keys, but many gaming keyboards now come with programmable keys and key macros, that could give you the extra functionality you're looking for.
Another possibility, if you're comfortable with programming at the level of C++, is to use the Windows Raw Input API, and plug in a second USB keyboard which your program could read a completely different set of input from.
https://learn.microsoft.com/en-us/windows/win32/inputdev/about-raw-input?redirectedfrom=MSDN
A third option might be to get a Raspberry Pi or Arduino to plug your keyboard into, and program it to read certain keys as your additional modifiers and send the desired output (as standard keyboard output) to your PC, with the Pi / Arduino acting as a "go-between" and emulating the keyboard. Maybe you could create your own Space-Cadet Keyboard this way.
I think the gaming keyboard with programmable keys will probably do what you're looking for, at the lowest cost and least time spent...

Is key 'chord' functionality provided by Win32/.net?

Several MS apps support the concept of chords, like CTRL + X , Y which means "holding down CTRL, press X, then Y".
Is this a bespoke thing they (and other companies) implement, or is it built into any APIs? It would be nice to be able to set up event handlers or accelerators based on chords rather than write code to do it.
'Accelerators' support normal key presses plus any combination of Shift, Ctrl, Alt.
For what you are asking for, I think you would need to process WM_KEYDOWN and WM_KEYUP yourself.
There are several solutions using GetKeyAsyncState from which you can directly derive which keys are currently up and down. Tracking every WM_KEYUP/DOWN is not easy and most naive solutions have issues with multiple apps and multiple threads.
A possible solution would be to detect the 'easy' part of the combination with an accellerator (i.e. the ctrl-Y) and then check whether the other keys (i.e. X) are down in the handler.

Resources