[Question]
  [
Most computer keyboards feature a small integrated LED light,
indicating the current input mode, as controlled with the CAPS LOCK button.
[![enter image description here](https://i.stack.imgur.com/cBlbN.jpg)](https://i.stack.imgur.com/cBlbN.jpg)
Your task is to blink it:
* Turn it on;
* Wait for 0.5 (+/-0.1) seconds;
* Turn it off again.
Video footage of the LED blinking is highly appreciated !
## Rules
* You can blink a different LED (e.g. Scroll Lock, Num Lock, Wi-Fi status etc), if you wish, but it must be physically located on your keyboard;
* If your language is missing a subsecond `sleep` command, your program may use a 1 second delay instead, at a penalty of +2 bytes (that's for `0.`);
* Your program must blink at least once, what happens afterward is up to you, i.e. it can continue to blink (in which case you must wait for the same delay, before turning it on again), or halt e.t.c.;
* If the chosen LED is ON by default, on your system, you can assume that it has been explicitly switched off (e.g. manually), before the program is run;
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), the shortest answer in bytes wins.
## Leaderboard
```
var QUESTION_ID=110974,OVERRIDE_USER=61904;function answersUrl(e){return"https://api.stackexchange.com/2.2/questions/"+QUESTION_ID+"/answers?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+ANSWER_FILTER}function commentUrl(e,s){return"https://api.stackexchange.com/2.2/answers/"+s.join(";")+"/comments?page="+e+"&pagesize=100&order=desc&sort=creation&site=codegolf&filter="+COMMENT_FILTER}function getAnswers(){jQuery.ajax({url:answersUrl(answer_page++),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){answers.push.apply(answers,e.items),answers_hash=[],answer_ids=[],e.items.forEach(function(e){e.comments=[];var s=+e.share_link.match(/\d+/);answer_ids.push(s),answers_hash[s]=e}),e.has_more||(more_answers=!1),comment_page=1,getComments()}})}function getComments(){jQuery.ajax({url:commentUrl(comment_page++,answer_ids),method:"get",dataType:"jsonp",crossDomain:!0,success:function(e){e.items.forEach(function(e){e.owner.user_id===OVERRIDE_USER&&answers_hash[e.post_id].comments.push(e)}),e.has_more?getComments():more_answers?getAnswers():process()}})}function getAuthorName(e){return e.owner.display_name}function process(){var e=[];answers.forEach(function(s){var r=s.body;s.comments.forEach(function(e){OVERRIDE_REG.test(e.body)&&(r="<h1>"+e.body.replace(OVERRIDE_REG,"")+"</h1>")});var a=r.match(SCORE_REG);a&&e.push({user:getAuthorName(s),size:+a[2],language:a[1],link:s.share_link})}),e.sort(function(e,s){var r=e.size,a=s.size;return r-a});var s={},r=1,a=null,n=1;e.forEach(function(e){e.size!=a&&(n=r),a=e.size,++r;var t=jQuery("#answer-template").html();t=t.replace("{{PLACE}}",n+".").replace("{{NAME}}",e.user).replace("{{LANGUAGE}}",e.language).replace("{{SIZE}}",e.size).replace("{{LINK}}",e.link),t=jQuery(t),jQuery("#answers").append(t);var o=e.language;/<a/.test(o)&&(o=jQuery(o).text()),s[o]=s[o]||{lang:e.language,user:e.user,size:e.size,link:e.link}});var t=[];for(var o in s)s.hasOwnProperty(o)&&t.push(s[o]);t.sort(function(e,s){return e.lang>s.lang?1:e.lang<s.lang?-1:0});for(var c=0;c<t.length;++c){var i=jQuery("#language-template").html(),o=t[c];i=i.replace("{{LANGUAGE}}",o.lang).replace("{{NAME}}",o.user).replace("{{SIZE}}",o.size).replace("{{LINK}}",o.link),i=jQuery(i),jQuery("#languages").append(i)}}var ANSWER_FILTER="!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe",COMMENT_FILTER="!)Q2B_A2kjfAiU78X(md6BoYk",answers=[],answers_hash,answer_ids,answer_page=1,more_answers=!0,comment_page;getAnswers();var SCORE_REG=/<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/,OVERRIDE_REG=/^Override\s*header:\s*/i;
```
```
body{text-align:left!important}#answer-list,#language-list{padding:10px;width:290px;float:left}table thead{font-weight:700}table td{padding:5px}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b"> <div id="answer-list"> <h2>Leaderboard</h2> <table class="answer-list"> <thead> <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr></thead> <tbody id="answers"> </tbody> </table> </div><div id="language-list"> <h2>Winners by Language</h2> <table class="language-list"> <thead> <tr><td>Language</td><td>User</td><td>Score</td></tr></thead> <tbody id="languages"> </tbody> </table> </div><table style="display: none"> <tbody id="answer-template"> <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table> <table style="display: none"> <tbody id="language-template"> <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr></tbody> </table>
```
  
[Answer]
# Befunge (BEF32), ~~390~~ ~~334~~ 305 bytes
This is really silly, but as long as this site accepts the notion that [the interpreter defines the language](http://meta.codegolf.stackexchange.com/a/7833/62101), I might as well abuse the rule. This code only works in Kevin Vigor's Win32 Befunge-93 Implementation, version 1.01 (I think the only version available). You can download the binary [here](http://www.club.cc.cmu.edu/%7Eajo/funge/quadium.net/funge/downloads/befun.zip).
```
p55p99+5p65*5p")"5p"M"3*"I~q"+\3*3445"|"2*"lm"2v
v"y"*3\*2"e/n"4\5"nnIn"*833*2"mn"4\7"nnIn"*833*<
>2*"yO"4"DJG"3*\2*55*3"T"4"DLG"3*\2*55*3"/~M"+\3*4446"~A"+4v
>+00p9p:v:"l'"*2"^D"4"l3"*2"^D"4"l"*54*2"^D"4"l"*2+94*2"^D"<
^1:g00-4_5"u1"*-:1+:1+"@"\0p"%"5*\0p"P"\0p@
Sleep kernel32.dll keybd_event user32.dll
```
Now normally you wouldn't expect this sort of challenge to be possible in a Befunge, but BEF32 is a Win32 port of a very old version of the reference implementation, and back then there was no bounds checking on the `p` (put) command. This effectively allows us to write to any location in memory, which ultimately lets us force the interpreter to execute arbitrary machine code.
Now we can't actually alter any of the existing code, since the .text section of the executable won't have write permissions. However, we can trick the system into executing an address in the .data section, by writing that address into the the runtime library's `atexit` table (at least I suspect that's what it is). The end result is that our code is automatically executed when the interpreter exits.
This relies on the fact that the executable is loaded at a fixed address, so we know exactly where everything is in memory - it assumedly wouldn't work if you overrode the default [ASLR](https://en.wikipedia.org/wiki/Address_space_layout_randomization#Microsoft_Windows) settings. It also relies on the .data section being executable, despite not having the executable attribute set, so again it most likely wouldn't work if you overrode the default [DEP](https://en.wikipedia.org/wiki/Executable_space_protection) settings.
The code itself is essentially a copy of [Mego](https://codegolf.stackexchange.com/users/45941/mego)'s `keybd_event` technique translated into machine code:
```
6823B84000         push "keybd_event"
682FB84000         push "user32.dll"
6810B84000         push "Sleep"
6816B84000         push "kernel32.dll"
BB02000000         mov  ebx,2
               initloop:
89C7               mov  edi,eax
FF1594D14000       call LoadLibraryA
50                 push eax
FF1590D14000       call GetProcAddressA
4B                 dec  ebx
75EE               jnz  initloop
89C6               mov  esi,eax
               flashloop:
6A00               push 0
6A01               push 1
6A45               push 69
6A14               push 20
FFD6               call esi
6A00               push 0
6A03               push 3
6A45               push 69
6A14               push 20
FFD6               call esi
68F4010000         push 500
FFD7               call edi
EBE3               jmp  flashloop
```
This version of the code continues flashing forever (or at least until you kill the process), since that turned out to be easier to golf than a single flash.
And since everyone is posting animations, this is an approximation of what it looks like on my keyboard.
![Animation of the capslock light flashing](https://i.stack.imgur.com/pBQTU.gif)
[Answer]
# AutoHotkey, ~~29~~ 26 bytes
*Thanks to @Dane for saving 3 bytes*
```
Loop{
Send,{VK14}
Sleep,500
}
```
I originally chose `NumLock` because it's one character shorter than `CapsLock`. The GIF below reflects that condition. It's the same effect as the altered code above. I could have gone with `VK90` above to make the GIF still be accurate but aligning with the original challenge felt better.
[![BlinkingNumLock](https://i.stack.imgur.com/Lkzpu.gif)](https://i.stack.imgur.com/Lkzpu.gif)
---
In honor of [mbomb007's comment](https://codegolf.stackexchange.com/questions/110974/blink-the-caps-lock#comment270217_110974), here's a morse code message in **239 bytes**:
```
s:=000090901009011091100110090111109111901090190110901109091000091001101909101191000911190190109100001090191010919111901091011
Loop,123{
StringMid,c,s,A_Index,1
IfEqual,c,9
{
Sleep,2000
Continue
}
Send,{NumLock}
Sleep,%c%500
Send,{NumLock}
Sleep,500
}
```
Here are the first 30 seconds of that message:
[![MorseCodeBlinking](https://i.stack.imgur.com/n6wHI.gif)](https://i.stack.imgur.com/n6wHI.gif)
[Answer]
# [GFA-Basic 3.51](https://en.wikipedia.org/wiki/GFA_BASIC) (Atari ST), ~~61 56 43~~ 35 bytes
This code will make the floppy drive LED blink forever at the required rate (`PAUSE 25` = pause for 25 / 50 second).
This would probably be shorter in assembly, but I don't have the appropriate tools at my fingertips. This is the size of the GFA-Basic listing once saved in .LST format and manually edited to remove useless whitespace, rename instructions to shorter strings and replace each `CR+LF` with a simple `CR`. Note that a final `CR` is required.
```
DO
i=i XOR2
SP &HFF8802,i
PA 25
LO
```
Will automatically expand to:
```
DO
  i=i XOR 2
  SPOKE &HFF8802,i
  PAUSE 25
LOOP
```
`SPOKE` is a supercharged `POKE` that first puts the 68000 in *supervisor* mode, so that it's allowed to access restricted memory areas (here: the *register write* address of the YM2149 soundchip, which is also responsible for some other I/O).
And yes: the LED is physically located on the keyboard ... I suppose.
[![ST Floppy LED](https://i.stack.imgur.com/LbkPc.gif)](https://i.stack.imgur.com/LbkPc.gif)
*I don't have access to a real ST right now, so this is just a mockup.*
[Answer]
# [fish](https://fishshell.com) + [ckb](https://github.com/ccMSC/ckb), ~~56~~ 54 bytes
```
while cd;echo rgb (random)|tee /d*/*/*/c*;sleep .5;end
```
Blinks my entire keyboard in random colors, though since the number isn't 6 hex digits long it's a bit limited.
![](https://i.stack.imgur.com/MSCNP.gif)
And yes, that shell glob is potentially dangerous. Works On My Machine™
Bonus script, 8 months later: This will go through all colors. Not golfed.
```
#!/usr/bin/fish
while true
        echo rgb (printf '%06x' (random 0 16777215)) | tee /dev/input/ckb*/cmd > /dev/null
        sleep 0.5
end
```
[Answer]
# Bash + amixer, 45 Bytes
```
a() { amixer set Master toggle
}
a;sleep .5;a
```
Blinks the mute light on my keyboard.
[![](https://i.stack.imgur.com/4S4s2.gif)](https://i.stack.imgur.com/4S4s2.gif)
[Answer]
## C (Windows), 79 bytes
```
#include<windows.h>
k(n){keybd_event(20,69,n,0);}f(){k(1);k(3);Sleep(500);f();}
```
### Explanation
[`keybd_event`](https://msdn.microsoft.com/en-us/library/ms646304%28VS.85%29.aspx) is a (deprecated) Windows API function to send a keyboard event (keyup or keydown). `20` is the code for the Caps Lock key, `69` is the hardware scan code (I have no idea what that means), and `1` means keydown and `3` means keyup. A keypress is simulated by sending a keydown event immediately followed by a keyup event. One keypress is sent to turn on Caps Lock, then the program sleeps for 500 milliseconds, and then another keypress is sent to turn Caps Lock back off.
Thanks to Steadybox for a bunch of bytes saved
[Answer]
## x86 machine code for PC (e.g. MS-DOS COM file), 27 bytes
This machine code (displayed here with a Unicode rendering of the usual CP437 of PC BIOS) will blink the CAPS LOCK indicator forever on a PC:
```
j@▼î▐j`Z░φεê╪εÇ≤♦╞♦◙Ç<☺t∩δ∙
```
The code has been made so it contains no NULL bytes, and can thus be typed with the keyboard (using the Alt+XXX trick for extended characters) to create a COM file (e.g., using the `COPY CON blink.com` command under MS-DOS, in which case the output file will have to contain a spurious 28th byte, the `^Z` (EOF) character required to stop the copy operation).
The effect is achieved by directly sending commands to the keyboard controller of the PC (port 60h) to set the LED state (as a side-effect, it might set Num Lock and Scroll Lock LEDs to a random non-blinking state). The timing, to minimize the number of instructions, is achieved by using the countdown timer maintained by the BIOS at address `0040:0040` (it decrements every 54.925 ms, with 9 cycles the blinking cycle is 494.3 ms, which is within the allowed margin) — this counter is normally used by the BIOS to stop the floppy disk motor; as the floppy drive is not used by the program and the code is assumed to run in a single-task environment (e.g. DOS), playing with the floppy motor timer is not an issue.
The code runs fine under MS-DOS (tried with VirtualBox, it should also run fine on real hardware, although I didn't have the time yet to make a bootable MS-DOS USB stick to test). As it doesn't rely on any OS functions, it can even run without the operating system (e.g., by placing it in the boot sector of a disk). It requires at least a 80186 processor to run, because of the "immediate push" instructions used to shorten the code of some bytes.
Assembly source code:
```
  PUSH 0x40               ; pushes 0x0040 (BIOS data segment) on the stack
  POP DS                  ; pops it into DS segment selector
  MOV SI, DS              ; copies DS to SI (timer counter is nicely placed at 40:40)
  PUSH 0x60               ; pushes 0x0060 (kbd controller port) on the stack
  POP DX                  ; pops it to DX
loop:
  MOV AL, 0xED            ; 8042 keyboard controller 'set mode indicators' command
  OUT DX, AL              ; outputs the command to the keyboard contr oller
  MOV AL, BL              ; copy BL register to AL
  OUT DX, AL              ; outputs LED state to keyboard controller
  XOR BL, 4               ; toggles bit 2 (CAPS LOCK) for next iteration
  MOV BYTE PTR[SI], 0x0A  ; sets floppy motor countdown timer to 10
wait:
  CMP BYTE PTR[SI], 0x01  ; checks if timer reached 1
  JE loop                 ; if yes, time for next iteration
  JMP wait                ; if not, checks again
```
Hexadecimal dump of the assembled code:
```
6A 40 1F 8C DE 6A 60 5A B0 ED EE 88 D8 EE 80 F3 04 C6 04 0A 80 3C 01 74 EF EB F9
```
Here is the result running under MS-DOS in VirtualBox (doesn't work with DosBox, presumably because the keyboard controller is not completely emulated):
[![Blinking CAPS LOCK](https://i.stack.imgur.com/vYaEP.gif)](https://i.stack.imgur.com/vYaEP.gif)
(sorry for the shaky video).
[Answer]
# MATLAB, ~~146~~ ~~136~~ 70
*Thanks to [@Poke](https://codegolf.stackexchange.com/users/51785/poke) for removing 66 bytes!*
```
r=java.awt.Robot;while 1
r.keyPress(20)
r.keyRelease(20)
pause(.5);end
```
This uses Matlab's ability to call Java classes. The Caps Lock light is blinked in a loop by programmatically pressing and releasing `Caps Lock`.
[Video or it didn't happen](https://youtu.be/QFBwFunc9qs).
[Answer]
# SmileBASIC, ~~36~~ 23 bytes
```
XON MIC
WAIT 30XOFF MIC
```
Blinks the microphone status light.
(video coming soon)
[Answer]
# Python2 - 108 bytes
Does the capslock key. Interestingly, this actually turns on just the LED itself without affecting the keyboard or pressing the key. You can change the `4` at the end to `2` to do numlock. `6` does both.
```
import fcntl,os,time;exec"fcntl.ioctl(os.open('/dev/console',os.O_NOCTTY),19250,%d);time.sleep(.5);"*2%(4,0)
```
[Answer]
# shell+numlockx, ~~40~~ 35 bytes
[Saved 5 bytes thanks to Ryan.]
Continually blinks the NumLock light on unixish systems.
```
numlockx toggle;sleep .5;exec sh $0
```
# Single blink, 33 bytes
```
numlockx on;sleep .5;numlockx off
```
[Answer]
# [PowerShell](https://github.com/PowerShell/PowerShell), 71 bytes
```
for(){(New-Object -c WScript.Shell).SendKeys('{NUMLOCK}');sleep -m 500}
```
### Notes
* Blinks forever
* Uses `NUM LOCK` to save a byte.
[Answer]
# VBS, 75 bytes
```
do
wscript.sleep 500
Createobject("wscript.shell").sendkeys"{numlock}"
loop
```
Repeatedly blinks Num Lock key, as `numlock` is 1 byte shorter than `capslock`.
[Answer]
## C#, ~~215~~ ~~202~~ ~~198~~ ~~195~~ 185 bytes
~~Without realising I have done the "same" code as [this answer by @Mego](https://codegolf.stackexchange.com/a/110985/38550), go check it out!.~~
```
[System.Runtime.InteropServices.DllImport("user32")]static extern void keybd_event(int v,int s,int f,int e);n=>{for(n=0;;System.Threading.Thread.Sleep(125))keybd_event(20,69,n++&2,0);};
```
*Saved 13 bytes thanks to @Metoniem*  
*Saved 10 bytes thanks to @VisualMelon*
Here's a full formatted version showing it working:
```
class P
{
    [System.Runtime.InteropServices.DllImport("user32")]
    static extern void keybd_event(int v, int s, int f, int e);
    static void Main()
    {
        System.Action<int> a = n =>
        {
            for (n = 0; ; System.Threading.Thread.Sleep(125))
                keybd_event(20, 69, n++ & 2, 0);
        };
        a(0);
    }
}
```
---
For bonus fun change `n++ & 2` to `n+=2 & 2` and watch the num lock and caps lock keys alternate in flashing on and off. I have no idea why that happens because it shouldn't but it looks "cool".
[Answer]
# Java 7, ~~121~~ ~~118~~ 113 bytes
```
void a()throws Exception{java.awt.Robot r=new java.awt.Robot();r.keyPress(20);r.delay(500);r.keyRelease(20);a();}
```
A single press and release just triggers the state; it doesn't blink it. Thus we may as well loop it and it looks like recursion is the cheapest manner of doing that.
[Answer]
# Linux terminal, 8+11 = 19 bytes
![demo](https://i.stack.imgur.com/l4vcn.gif)
File `f` = `1B 5B 33 71 1B 5B 30 71`
`native@shell:~$` `pv f -q -L8`
## WAT?
According to [ECMA-48](https://en.wikipedia.org/wiki/ANSI_escape_code), `1B` starts terminal control escape sequence.
Caps on =`1B 5B 33 71`, then off = `1B 5B 30 71`
`pv` progress view
`f` file
`-q` quiet
`-L8` 8 bytes/s = 0.5 sec delay
## Usage
Prepare
```
#Create file
echo "1B 5B 33 71 1B 5B 30 71"|xxd -r -p > f 
#Install progress view utility
sudo apt install pv
```
`Ctrl`+`Alt`+`F6` switch to native console
run `pv f -q -L8`
`Ctrl`+`Alt`+`F7` switch back
[Answer]
**JavaScript, 82 bytes**
**Credit goes to @FinW** actually, I just changed old function to new ES6 arrow function in order to save some bytes. And becuase I don't have enough points to comment I wrote a new reply.
Edit - deleted brackets to save another 2 bytes.
```
o=new ActiveXObject("WScript.Shell");setInterval(()=>o.SendKeys("{NUMLOCK}"),500);
```
His code looked like this
```
o=new ActiveXObject("WScript.Shell");setInterval(function(){o.SendKeys("{NUMLOCK}")},500);
```
[Answer]
# Scala, 84 83 78 bytes
### Edit: Saved 1 byte thanks to @TheLethalCoder,
He suggested using `1>0` in place of `true`.
### Edit 2: Saved 5 bytes thanks to @Corvus\_192,
He suggested using infix notation and dropping the parentheses after the constructor
```
while(1>0){val r=new java.awt.Robot;r keyPress 20;r keyRelease 20;r delay 500}
```
## Ungolfed:
```
while(1>0) {
    val r=new java.awt.Robot()
    r.keyPress(20)
    r.keyRelease(20)
    r.delay(500)
}
```
Standard Scala port of [@Poke](https://codegolf.stackexchange.com/users/51785/poke)'s Java [answer](https://codegolf.stackexchange.com/a/110983/48620). Type it directly into the Scala interpreter prompt.
A video of it blinking both my Caps Lock LED and my OSD to boot!
![Blinking Caps Lock LED and OSD](https://i.stack.imgur.com/gxC8e.gif)
[Answer]
**Bash, 31 bytes**
```
xset led 1;sleep .5;xset -led 1
```
Works in X, without root access ! (If it does not work for you, see the init function of the code below to make sure xkbcomp is configured correctly)
And a bonus script to send any morse code through caps lock (not golfed) :
```
unit=0.15
id=1
function init {
        file=/tmp/blink_tmp
        xkbcomp $DISPLAY $file
        sed -i 's/!allowExplicit/allowExplicit/' $file
        xkbcomp $file $DISPLAY &>/dev/null
        rm $file
}
if [[ -z $1 ]]; then
        echo "Usage : blink [message]"
        exit 1
fi
init
function finish {
        off
}
function on {
#su -c 'setleds -L +caps < /dev/console'
xset led $id
}
function off {
#su -c 'setleds -L -caps < /dev/console'
xset -led $id
}
function slp {
        sleep $(echo "$unit*$1" | bc)
}
function dot {
on
slp 1
off
slp 1
}
function dash {
on
slp 3
off
slp 1
}
function gap {
        slp 3
}
function morse {
        msg=$1
        for (( i=0; i<${#msg}; i++ )); do
                char=${msg:$i:1}
                if [[ $char == "-" ]]; then
                dash
                elif [[ $char == "." ]]; then
                dot
                elif [[ $char == "/" ]]; then
                gap
                fi
        done
}
while true; do
        morse $1
done
```
Exemple : `blink "...././.-../.-../---//.--/---/.-./.-../-..///"`
[Answer]
**Bash + Xdotool, 36 bytes**
```
for((;;)){ xdotool key 66;sleep .5;}
```
Just execute it in a bash shell. It needs to be in a graphical environment. Infinite loop from [here](https://codegolf.stackexchange.com/questions/15279/tips-for-golfing-in-bash). Changed Num\_Lock to 66 to save 6 bytes, and thanks to @Michael Kjörling for 2 bytes.
[Answer]
# [xdotool](//semicomplete.com/projects/xdotool/), 20 bytes
```
key -delay=500 66 66
```
Presses the key **66** aka *Caps Lock* twice, with a delay of **500 ms** between key presses.
Note that xdotool is a scripting language; it can be run from a file and it even supports shebangs. Since its `exec` command allow running external programs, it is capable of addition and primality testing, so it satisfies our definition of programming language.
### Test run
```
$ cat blink.xdo; echo
key -delay=500 66 66
$ xdotool blink.xdo
```
[![enter image description here](https://i.stack.imgur.com/vX4cp.gif)](https://i.stack.imgur.com/vX4cp.gif)
[Answer]
# Python using pyautogui: 126 143 115 103 bytes
*Thanks to @nedla2004 for saving 12 bytes* 
```
from pyautogui import*
import time
while 1:keyDown('capslock');time.sleep(.5);keyUp('capslock')pslock')
```
[Answer]
# Bash + [setleds](https://github.com/damieng/setledsmac), 43 bytes
```
setleds -D +caps;sleep 0.5;setleds -D -caps
```
Pretty simple. Uses `setleds` to toggle the light.
[Answer]
# Bash, 103 bytes
```
cd /sys/class/leds/asus\:\:kbd_backlight;while true;do echo 3;sleep .5;echo 0;sleep .5;done>brightness
```
Must be run as root.
Does flashing the entire keyboard backlight work? (video to come when I get home)
[Answer]
# JavaScript, 90 bytes
```
o=new ActiveXObject("WScript.Shell");setInterval(function(){o.SendKeys("{NUMLOCK}")},500);
```
It requires `ActiveX` meaning it will only run on IE (Edge *doesn't* support it, though). It flashes the NUMLOCK key because, as with other answers, it is shorter than CAPSLOCK or SCROLLLOCK.
## Ungolfed
```
shell = new ActiveXObject("WScript.Shell");
setInterval(
    function(){
        shell.SendKeys("{NUMLOCK}")
    }
,500);
```
[Answer]
# Bash, 33 Bytes
This assumes Num-Lock to be on before it is run. Switch `off` and `on` otherwise. Requires the `numlockx` package obviously ;)
```
numlockx off;sleep .5;numlockx on
```
**Edit:**
Saw Alex Howansky has already posted this solution, yet not marked it with Bash and I just searched the site for "Bash".
[Answer]
# Batch File (With help of vbs), 74+2=76 bytes
```
echo Createobject("wscript.shell").sendkeys"{numlock}">z.vbs&z&timeout 1&z
```
Partially based on [Trelzevir's answer](https://codegolf.stackexchange.com/a/110978).
`.vbs` is automatically included in `PATHEXT`.
[Answer]
# [C (msvc)](https://visualstudio.microsoft.com/vs/features/cplusplus/) + Win32, 51 bytes
```
main(i){main(i+keybd_event(20,69,i%4,Sleep(125)));}
```
[![enter image description here](https://i.stack.imgur.com/8wma5.gif)](https://i.stack.imgur.com/8wma5.gif)
[Answer]
## Kotlin Script, 72 bytes
While not smallest one, still it's pretty good. I'm loving kotlin's *run* for some things, and this is one of them ( smaller than val r = java.awt.Robot() because we don't need both r. and val r =. Still, it's longer than MathLab )
```
java.awt.Robot().run{while(1>0){keyPress(20);keyRelease(20);delay(500)}}
```
## Ungolfed:
```
java.awt.Robot().run {
    while(1>0) {
        keyPress(20)
        keyRelease(20)
        delay(500)
    }
}
```
[Answer]
# Python3 , 55 49 bytes
*Thank you @NoOneIsHere for -4 bytes!*    
This includes packages: [pyautogui](http://pyautogui.readthedocs.io/en/latest/install.html) and `time` modules   
Code:
```
while(1):pag.press("capslock");time.sleep(0.5)  
```
Thank you @NoOneIsHere for -4 bytes!   
The key in action:   
[![Caps Lock](https://media.giphy.com/media/ckihNChuUTohW/giphy.gif)](https://media.giphy.com/media/ckihNChuUTohW/giphy.gif)
]