Scan Codes of the Buttons

896 views
Skip to first unread message

muellmail...@gmail.com

unread,
Mar 9, 2014, 5:17:36 PM3/9/14
to typematrix...@googlegroups.com
I want to "copy", "cut" and "paste" reprogram so that I can use them without the Fn key, so do not set a hotkey but as a single button.

Have various attempts with Sharp Keys and KeyTweak. It did not work.

I think it would be helpful if I had the scan codes for the three keys "paste", "insert" and "copy".

Is it possible to know the scan codes?

Thank you.

TypeMatrix Admin

unread,
Mar 9, 2014, 7:22:43 PM3/9/14
to typematrix...@googlegroups.com
Hello,

This is unfortunately a little more involved than would seem at first. The Cut, Copy and Paste functions are actually implemented as key-sequences Cut is "Shift" + "Delete", Copy is "Ctrl"+"Insert" and Paste is "Shift"+"Insert". We picked these because different OS manufacturers are somehow unable to agree on a standard, and these are the most widely supported across all systems.

However there is hope yet: the USB HID codes (USB doesn't really use scan codes anymore) for the play/pause button is Usage ID "36", Type "OOC", and the application context menu key to the right of it is Usage ID "84", Type "OSC". The application shuffle key is unfortunately again a sequence "Alt"+"Tab". So you could map copy and paste on top of play/pause and context-menu to get you most of what you want (if you can live without cut).

One caveat: in the 102 key mode (Fn+102) and 106 key mode (Fn+F3) the pause/play button is remapped as the "\" and "|" key (Usage ID "49" on the "boot" page), but in 106 mode the application shuffle key is remapple.. although I can't readily find out what HID code it sends, I'll have to look into that.

Hope this helps you get started on the right way. Here is a very detailed useful document on USB HID codes: http://www.usb.org/developers/devclass_docs/Hut1_11.pdf

Let us know if you get this working and how =) 
Thanks,

-Mary @Tmx



True Falcon

unread,
Mar 9, 2014, 7:45:15 PM3/9/14
to typematrix...@googlegroups.com
Scan codes? That's easy.  Here you go, courtesy of AutoHotKey:

VK=Virtual Key, SC=Scan Code

VK  SC    Up/Dn    Elapsed    Key

A0  02A   d      LShift          fn-cut sends L Shift-Delete
2E  153   d      Delete         
A0  02A   u      LShift         
2E  153   u      Delete         

A2  01D   d      LControl        fn-copy sends L Control-Insert
2D  152   d      Insert         
A2  01D   u      LControl       
2D  152   u      Insert         

A0  02A   d      LShift          fn-paste sends L Control-Insert
2D  152   d      Insert         
A0  02A   u      LShift         
2D  152   u      Insert     

B3  122   d      Media_Play_Pause     play sends Media_Play_Pause
B3  122   u      Media_Play_Pause

5D  15D   d      AppsKey         app sends ??? something like a right-click or F10 context menu command.
5D  15D   u      AppsKey        

A4  038   d      LAlt            shuffle sends L Alt-Tab
09  00F   d      Tab            
09  00F   u      Tab            
A4  038   u      LAlt

and just for completeness ...

5B  15B         d    6.72    LWin       dsktp sends Windows D
44  020         d    0.00    D                 
5B  15B         u    0.01    LWin 
44  020         u    0.00    D    


All these keys are all hard coded to send what you see above.  You can't stop them from sending that.

Cut, Copy, Paste, Shuffle, and DskTp all send 4 scan codes (keys down, keys up).  They emulate other keystrokes.  I haven't tried to reprogram these keys at all. Adding another scan code to what they already send could end up very messy!  ;-)

Play and App send one code so you could tell them to send something additional ... but they would still send their hard coded stuff.

The apps key I kind of like ... it's handy.  Instead of right-click, mouse down I can do it all from the keyboard.

I have told the Play key to send a single left mouse click wherever the pointer currently is.  I can just point with my left hand on my Logitech Performance MX mouse and click with the left.  Handy for lazy browsing.   However it stills send Play/Pause but I use VLC media player and it doesn't react to this key.

As for cut, copy and paste, I never use the fn-### keys.  I use Ctrl-x, c, and v.  Works for me.

I currently have 3500 lines in my autohotkey.ini file; it's the best I've found for hotkeys and macros.  It can even move and click the mouse.

TF

Robert Lee

unread,
Mar 10, 2014, 7:10:04 PM3/10/14
to typematrix...@googlegroups.com
It's unfortunate there is no mechanism on the keyboard to effect a HID only mode. No <alt> <tab> <wtf> sequences for those who desire total configurability.

TypeMatrix Admin

unread,
Mar 16, 2014, 7:05:12 PM3/16/14
to typematrix...@googlegroups.com
The closest thing we have to this is the 106 key mode ( fn + F3 ):

The "106" key layout is used primarily for compatibility with remapping software. It changes the following 6 keys:

  • The "shuffle" key becomes scan code 123/0x7B (Alt 4)
  • The "desktop" key becomes scan code 121/0x79 (Alt 2)
  • The "www" key becomes scan code 112/0x70 (Alt F9)
  • The "calc" key becomes scan code 125/0x7D (Alt 6)
  • The backslash key is moved to where the "mail" key used to be (scan code 43/0x2B - \ or |)
  • The key where the backslash used to be becomes scan code 115/0x73 (Ctrl L Arrow)

This configuration is frequently used by people who use key remapping software, because it allows remapping of the former shuffle and desktop keys which would otherwise be not reprogrammable hardcoded key combinations.

(The odd choice of keys really has to do with this originally being designed for some asian languages, but many of our "remapping-friendly" users use it as well)

- Mary @ Tmx

Антон Кириченко

unread,
Oct 22, 2014, 10:09:34 PM10/22/14
to typematrix...@googlegroups.com
Hi, I don't know if this is a proper place to ask, but my problem is pretty similar. I wan't to remap left shift button to left alt on arch linux, xbindkeys won't work for me because I use keyboard with synergy to work in pair with macbook, and I need to make remap before x server. So I tried it with udev and setkeycodes, as this manual suggest, but it didn't worked. Here is my steps for setkeycodes way:

in terminal with X run, I execute showkey --scancodes, and pressing left shift, and getting two numbers:

0x2a
0xaa

I don't really know why it has such format, but anyway, I tried all possible variants like

setkeycoodes 2aaa 50
setkeycoodes 2a 50
setkeycoodes aa 50

and even tried some code I got from xev:

setkeycodes ffe1 50

But I constantly get 

KDSETKEYCODE: Invalid argument
failed to set scancode ..

error. Can anyone suggest what am I doing wrong? thanks.

P.S. I found some post with such an answer that you should use evtest to get proper scancode. Could not install it on arch though.

Антон Кириченко

unread,
Oct 22, 2014, 10:11:36 PM10/22/14
to typematrix...@googlegroups.com
sorry, I meant 'with not running X server for showkey'

Антон Кириченко

unread,
Oct 23, 2014, 8:25:59 PM10/23/14
to typematrix...@googlegroups.com
is anyone here?

Reinard Dolleschel

unread,
Oct 24, 2014, 2:38:48 PM10/24/14
to typematrix...@googlegroups.com
Hey there,

I'm not an expert with this at all but a little googling shows that your first example

setkeycodes 2aaa 50

should be correct. The kernel will add 8 to the keycode, so remember to to map your action to 58, not 50.

make sure you get the right values by running "sudo showkey -s"

take a look at this:

this may also be helpful:

Let us know what ends up working in case someone else looks for this info later =)

Thanks!

Антон Кириченко

unread,
Nov 5, 2014, 7:45:48 AM11/5/14
to typematrix...@googlegroups.com
nope, still getting error

sandric@sandric-media ~> sudo setkeycodes 2aaa 58
KDSETKEYCODE: Invalid argument
failed to set scancode 2aaa to keycode 58
sandric@sandric-media ~> sudo setkeycodes 2a 58
KDSETKEYCODE: Invalid argument
failed to set scancode 2a to keycode 58

Reinard Dolleschel

unread,
Nov 5, 2014, 5:58:04 PM11/5/14
to typematrix...@googlegroups.com
What do you get when you do a 

sudo showkey -s
and then push the button?

Andrew Bogorodsky

unread,
Nov 24, 2017, 4:38:26 PM11/24/17
to TypeMatrix User Group
Dear Stu!

You've written "I currently have 3500 lines in my autohotkey.ini file" - how to obtain that file?
Also i know that VK 2E SC 124 == "Cut" HID button. Do you have any idea about the same number ID for "Copy" and "Paste" keys?
Reply all
Reply to author
Forward
0 new messages