g++ : How can I get keystate on linux - linux

I Want to get keystate for some key like shift. If I press "a" with shift to write "A" then by g++ program on linux how can I ensure that shift is also pressed while I press key "a".
Thanks in advance.

See the answer for this question: What is Equivalent to getch() & getche() in Linux?
It will give you the correct keycodes, i.e. 'a' if you press 'a' with shift depressed, 'A' if you press it with shift pressed, etc. Getting the state of the shift key alone is a different matter though, I'm not sure if there's an easy way to do that.

Related

Allow hotkey that presses a disabled key

My keyboard key/letter f is ruined and continuously presses the letter. I am using AutoHotKey to successully disable the letter, but I need an alternative hotkey to press the key. I have chosen to use CTRL+j as the hotkey to press the letter f. I tried this script but it does not seem to press the key:
f::return
^j::
Send f
return
I also tried this but it also does not work:
f::return
^j::
Send {f down}
return
How can I get the script to press f using the hotkey CTRL+j, while disabling the key f?
The $ modifier is going to solve this problem.
That modifier makes it so that your f::return hotkey wont affect keys that are sent from AHK.
So here's your finished script:
$f::return
^j::SendInput, f
Also switched over to SendInput due to it being the recommended faster and more reliable send mode.
I used the ASCII code for the letters in both uppercase and lowercase, and it also worked:
; disable the key 'f':
f::return
; press CTRL+j to press f:
^j::
Send {Asc 102}
return
; press CTRL+Shift+j to press F:
^+j::
Send {Asc 70}
return

How to make vim print the key i pressed directly when i have mapped this key with another one?

When I map 2 keys together for example <Tab><Space> and press the first one Vim will first wait to see if i press Space before printing the tabulation.
I would like to know if it is possible to make vim print the tabulation first and then waiting for an eventual Space key for mapping.
Thank You !

How to type Ampersand with Key '7' Broken using Keyboard?

If this question doesn't suit here, request me , I will take it off.
My keyboard's 7 key got damaged and I can't type ampersand without struggling. I am into C programming and can't buy a keyboard right now. Is there any way I can map it somewhere? I am using Ubuntu OS.
Use xev command to find the keycode of the key you want to use instead of ampersand and run the following command
xmodmap -e "keycode xxx = ampersand"
Where xxx is the keycode you found.

Detect right and left shift keys pressed together from within Awesome WM

I want to have Awesome WM run a command when both Shift keys (left and right) are pressed together.
I know Linux can differentiate between the two shift keys (e.g., one can tell Gnome to change the keyboard layout when both Shift keys are pressed together).
Is there a way to do this in Awesome?
It is realy very simple, you can set the "Shift" (left shift) as mod key and #62 (right shift) as pressed key. Tested it just now and with me it works.
for instance if I want firefox to spawn I do this:
awful.key({ "Shift" }, "#62", function () awful.util.spawn(browser) end),

OSX: Remap Caps Lock as a modifier key likey cmd

The standard layout on an a macbook pro is not quite efficient if one wants to do a lot of programming. I want to change that with some small tweaks.
One of those would be: Change Caps Lock to be a key like cmd and ctrl. For example if I want to write '{' I want to press 'Caps + a'.
Is that possible?

Resources