# Keybow mini - copy-past shortcuts problem

**URL:** <https://forums.pimoroni.com/t/keybow-mini-copy-past-shortcuts-problem/22699>\
**Category:** Support\
**Created:** [August 12, 2023, 1:19pm UTC](https://forums.pimoroni.com/t/keybow-mini-copy-past-shortcuts-problem/22699 "2023-08-12T13:19:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vjdobermann](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/vjdobermann/32/10006_2.png) [@vjdobermann](https://forums.pimoroni.com/u/vjdobermann)\
**Post date:** [August 12, 2023, 1:19pm UTC](https://forums.pimoroni.com/t/keybow-mini-copy-past-shortcuts-problem/22699/1 "2023-08-12T13:19:43Z")

</div>

Hi everyone,  
i’m completely newbie on programing…  
I’ve bought the Keybow mini and i’ve followed the macros tutorial.

The goal is to create 3 shortcuts : save/copy/paste  
Below the code :

```auto
function handle_minikey_00(pressed)
        keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_DOWN)
        keybow.tap_key("v", pressed)
        keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_UP)
    if pressed then
        keybow.set_pixel(0, 255, 0, 0)
    else
        keybow.set_pixel(0, 0, 0, 0)
    end
end

function handle_minikey_01(pressed)
        keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_DOWN)
        keybow.tap_key("c", pressed)
        keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_UP)
    if pressed then
        keybow.set_pixel(1, 0, 255, 0)
    else
        keybow.set_pixel(1, 0, 0, 0)
    end
end

function handle_minikey_02(pressed)
        keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_DOWN)
        keybow.tap_key("s", pressed)
        keybow.set_modifier(keybow.LEFT_CTRL, keybow.KEY_UP)
    if pressed then
        keybow.set_pixel(2, 0, 0, 255)
    else
        keybow.set_pixel(2, 0, 0, 0)
    end
end

```

this issue occurs when pressing the key 00 for pasting (a text for eg), it pasts twice.  
first it pasts the text when the key is pressed and secondly when the key is released.

How can I fixe it please ?  
thanks in advance for your help

---

<div class="post-metadata">

**Author:** ![vjdobermann](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/vjdobermann/32/10006_2.png) [@vjdobermann](https://forums.pimoroni.com/u/vjdobermann)\
**Post date:** [August 21, 2023, 10:57am UTC](https://forums.pimoroni.com/t/keybow-mini-copy-past-shortcuts-problem/22699/2 "2023-08-21T10:57:06Z")

</div>

ok after a few search, below the correct code.  
(the one on the tutorial is wrong)

> require “keybow”
> 
> – Keybow MINI –
> 
> function setup()  
> keybow.use\_mini()  
> keybow.auto\_lights(false)  
> keybow.clear\_lights()  
> end
> 
> – Key mappings –
> 
> function handle\_minikey\_00(pressed)  
> if pressed then  
> keybow.set\_modifier(keybow.LEFT\_CTRL, keybow.KEY\_DOWN)  
> keybow.tap\_key(“v”, pressed)  
> keybow.set\_modifier(keybow.LEFT\_CTRL, keybow.KEY\_UP)  
> keybow.set\_pixel(0, 255, 0, 0)  
> else  
> keybow.set\_pixel(0, 0, 0, 0)  
> end  
> end
> 
> function handle\_minikey\_01(pressed)  
> if pressed then  
> keybow.set\_modifier(keybow.LEFT\_CTRL, keybow.KEY\_DOWN)  
> keybow.tap\_key(“c”, pressed)  
> keybow.set\_modifier(keybow.LEFT\_CTRL, keybow.KEY\_UP)  
> keybow.set\_pixel(1, 0, 255, 0)  
> else  
> keybow.set\_pixel(1, 0, 0, 0)  
> end  
> end
> 
> function handle\_minikey\_02(pressed)  
> if pressed then  
> keybow.set\_modifier(keybow.LEFT\_CTRL, keybow.KEY\_DOWN)  
> keybow.tap\_key(“s”, pressed)  
> keybow.set\_modifier(keybow.LEFT\_CTRL, keybow.KEY\_UP)  
> keybow.set\_pixel(2, 0, 0, 255)  
> else  
> keybow.set\_pixel(2, 0, 0, 0)  
> end  
> end

---

<div class="post-metadata">

**Author:** ![ahnlak](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/ahnlak/32/5610_2.png) [@ahnlak](https://forums.pimoroni.com/u/ahnlak)\
**Post date:** [August 21, 2023, 3:18pm UTC](https://forums.pimoroni.com/t/keybow-mini-copy-past-shortcuts-problem/22699/3 "2023-08-21T15:18:40Z")

</div>

Which tutorial is it that’s got the wrong code? The [“Using Macros” one on learn](https://learn.pimoroni.com/article/using-macros-and-snippets-with-keybow) looks to have the key tap stuff correctly wrapped inside `if pressed` blocks?

---

<div class="post-metadata">

**Author:** ![vjdobermann](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/vjdobermann/32/10006_2.png) [@vjdobermann](https://forums.pimoroni.com/u/vjdobermann)\
**Post date:** [August 26, 2023, 9:49am UTC](https://forums.pimoroni.com/t/keybow-mini-copy-past-shortcuts-problem/22699/4 "2023-08-26T09:49:59Z")

</div>

Yes the code came from this page that I’ve been inspired.  
I’ve copy-past and it doesn’t work.  
after talking with a friend more comfortable on programming, he told me how to fix the code :

 ![WhatsApp Image 2023-08-12 at 19.34.58](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/b/bc5670db3dee1f3b281901b2226e429a664c1d89.jpeg)
