0

I spilled the tiniest amount of water on my laptop and now the left arrow key won't respond - can anyone give me a quick runthrough of how to reassign it (i'm using Ubuntu) to another key (probably the right ctrl or another)?

If the tutorial requires me to press the left arrow key (perhaps to get its binding ID or something) I won't be able to do that.

Thanks!

jobin
  • 27,708

1 Answers1

2

setkeycodes can then be used to re-assign scancode to keycode mappings.

(only know of, because usually the caps-lock are the first ones I disable)

sudo setkeycodes E01D 105

where E01D is the scancode for right-ctrl and 105 is the keycode for cursor-left.

There's even a visual editor for the mapping, I just found:

set context menu key to function as right control

  • how exactly do I work out which key is the left arrow key? I just a bunch of random numbers when I run getkeycodes – Alexander Giles Nov 10 '13 at 15:15
  • try dumpkeys - is a rather human-readable format... here it's mapped to keycode 105 = Left – Martin Zeitler Nov 10 '13 at 15:20
  • just be aware that on a notebook keyboard this might vary. – Martin Zeitler Nov 10 '13 at 15:26
  • OK so keycode 105 is for the left arrow - what is the setkeycodes command to set this to the right control? – Alexander Giles Nov 10 '13 at 15:30
  • 1
    updated answer - without ANY guarantee, please validate. – Martin Zeitler Nov 10 '13 at 15:40
  • What's your scan code for the left control (the usual ctrl)? – Alexander Giles Nov 10 '13 at 15:52
  • Ok I got it working - thanks so much! You answer is by far the simpliest. Just to clarify I used sudo setkeycodes 1d 97 to set the left control back to the left control. SO 1) find the scan code (call it A) - this can be found on a list online just type what is the can code of ... - and use dumpkeys to find the keycode (call it B). Then just use sudo setkeycodes A B – Alexander Giles Nov 10 '13 at 15:57
  • Here's the simple way to reassign keys...
    1. Find the scan code of the the key you want to assign something to (for example this is 1d for the left control - see http://www.win.tue.nl/~aeb/linux/kbd/scancodes-1.html for a list of what these are. You can also use sudo showkeys -s

    2. Use sudo dumpkeys to find the 'keycode' for the key you want to move (left arrow is 105 on my machine for example - may vary depending on machine)

    3. dial in sudo setkeycodes 1d 105 ---> this makes your machine perform 'left arrow' whenever you press the left cntrl key.

    – Alexander Giles Nov 10 '13 at 16:10
  • 1
    validating is always better - because I've sometimes seen exotic notebook keyboards which had certain keys mapped strangely (ones from far east in combination with euro keyboards). – Martin Zeitler Nov 10 '13 at 16:26
  • 1
    showkey --scancodes & xev are also useful for finding the codes.... while evtest seems to be useful, in particular for USB keyboard events. – Martin Zeitler Jan 27 '18 at 08:18