Getting Scroll Lock to Work in Ubuntu

7 04 2008

For some odd reason the Scroll Lock button doesn’t work in an Xsession in Ubuntu. There’s an old bug report here. However it works as it should in a virtual terminal. :? The interesting thing though is that Xev will detect the key press. So how do you get the Scroll Lock functioning again? Well first let’s run this command

xmodmap -pm

You should get an output like this

xmodmap:  up to 3 keys per modifier, (keycodes in parentheses):

shift       Shift_L (0×32),  Shift_R (0x3e)
lock        Caps_Lock (0×42)
control     Control_L (0×25),  Control_R (0x6d)
mod1        Alt_L (0×40),  Alt_L (0x7d),  Meta_L (0x9c)
mod2        Num_Lock (0x4d)
mod3
mod4        Super_L (0x7f),  Hyper_L (0×80)
mod5        Mode_switch (0x5d),  ISO_Level3_Shift (0x7c)

Notice mod3 has nothing listed.  This will be what we will use to assign Scroll Lock.  It may be a different mod for some people.  Either way use the one that has nothing listed.

Before we do anything else let’s test this to make sure it works.  We’re going to run this command

xmodmap -e ‘add mod3 = Scroll_Lock’

Replace mod3 with whatever the blank mod listing was.  Your Scroll Lock should work now.

I hate making changes like this locally to only my user, so I’m going to do this globally.

Now we need to create a file in /etc/X11 called Xmodmap.  So start up Gedit or your favorite text editor

gksudo gedit /etc/X11/Xmodmap

Now add this to the file

add mod3 = Scroll_Lock

again, change mod3 to the one that was empty from the first command.  Now the Scroll Lock key should get set when X starts now. :)

About these ads

Actions

Information

24 responses

29 05 2008
Srinivas

Very informative!

19 08 2008
mayurjain

thanks man…i used this info go get my Trendnet KVM switch to work…it uses the key sequence “ScrLock + ScrLock” and my ubuntu wont recognize this…

6 09 2008
proh

for KVM use in Linux try use NumLock instead of ScrLock. But anyway better fix this

3 11 2008
Rich

Thanks a lot, dude!

11 11 2008
Bart

Thanks man !
What a strange bug! I also needed this for my KVM switch

27 03 2009
Mike

Excellent info. I’ve used this in 8.04 to get my KVM working. I’ve recently upgraded to Intrepid Ibex 8.10, and it stopped working again. It appears that Xmodmap is no longer used and this must be taken care of though HAL. I’ve managed to do some tweaks to my mouse with a .fdi file. It looks like the same needs to be done to get scroll lock working again. How about an update here to show us noobs how it’s done? :)

6 05 2009
Soren

Hey

Thanks for the info ! I have used it on a number of Ubuntu 8.04 boxes with success.

However if a make the mod in 9.04 it kills the alt-gr button. (The right alt key, which is frequently used on a danish keyboard layout as mine).

Does anyone know a workaround for this ?

11 05 2009
btxshark

I just upgraded to 9.10 and this will not work. is there a way to do this with newer versions or am SOL. also, i have been having problems with the flash plugins, i am not sure if this is just my hardware (which is very old) or if there is a known bug.

21 08 2009
Curtis

I am having the same issue, I’m using Ubuntu 9.04 and the scroll lock will still not work using both methods described

19 11 2009
Richard

I fixed the problem in Intrepid Ibex and Jaunty by creating the file ~/.Xmodmaprc (in my home directory). This file is picked up by X upon login. The file contains the following :

add mod3 = Scroll_Lock

The first time you log in after the creating .Xmodmaprc, the system will ask you if you want to load .Xmodmaprc. The next time you log in, it will not ask you unless you delete the Gnome configuration file for the keyboard modifications located in :

/home/rbo83/.gconf/desktop/gnome/peripherals/keyboard/general/%gconf.xml

13 04 2010
MaxF

Excellent answer!!

14 06 2010
Miguel

Waawww Muchas gracias!! me estaba volviendo loco ya con la jodida tecla xD

Un saludo!

25 06 2010
w-9868 keyboard scroll lock issue with ubuntu 10 | Trevyn Meyer Blog of Stuff

[...] and found linux on occation is missing the traditional scroll lock.  I foudn a good article here: that siad [...]

7 08 2010
Ben

Oh, wow. You are a genius! I have an LED backlit keyboard that will only light up if the Scroll Lock is pressed. Your’re a life saver!

So why isn’t the scroll lock enabled in the first place? It seems like this would be something pretty standard, wouldn’t it?

2 01 2011
2010 in review « Linuxtechie's Blog

[...] Getting Scroll Lock to Work in Ubuntu April 2008 14 comments [...]

4 06 2011
Jon Q

Doesn’t work in Knoppix – it “looks” like it works, there’s no error in the terminal, and xmodmap -pm returns as it should (with mod3 being set to scroll lock), but scroll lock still doesn’t actually work.

Very frustrating.

31 08 2011
Elaine

This is great – a fantastic tutorial as have been having problems with NumLock and CapsLock – it works in Ubuntu Lucid 10.04. When 10.04 first came out – all was working fine but since it was first released the CapsLock, NumLock and ScrollLock all disappeared! Very bizarre! Anyway this is a great way to fix it as I thought it was my keyboard (been using the Microsoft wired keyboard 500 and the Acer keyboard – both set up as generic layout with using Generic 105-key (Intl) PC keyboard.

Many thanks for your help.

26 12 2011
ricky

Thanks, had a new keyboard for xmas, thought the led light for the scroll-lock was damaged.

Followed your instructions on Arch Linux, worked as expected…. many thanks!

2 03 2012
freyverres

Still works for me in Ubuntu 11.10. Awesome. Thanks!

2 01 2013
wyatt8740

Still works as of Ubuntu 12.04. Just sayin’

4 01 2013
livinjean

I know I am pretty late to the party, but here are my 2 cents.

In my archbang setup the xmodmap solution did not work, but installing numlockx and creating a numlockx on/off script did the trick.

The numlockx solution is listed here (check comment #2) ,
http://ubuntuforums.org/showthread.php?p=11789416

11 01 2013
qzjul

The xmodmap solution is not working for me in 12.04 now =( worked in 8.04;

The scroll lock light *is* fixed, but the toggling of the light doesn’t trigger the KVM for some reason; works fine on my 8.04 and windows boxes though…

11 01 2013
Irondrake

This also fixed my issue on Red Hat 5

very niche! Thank you!

12 03 2014
Bruno

You saved my life

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s




Follow

Get every new post delivered to your Inbox.

Join 25 other followers

%d bloggers like this: