# I can't pass a lambda to on\_button\_event in Python

**URL:** <https://forum.makecode.com/t/i-cant-pass-a-lambda-to-on-button-event-in-python/2969>\
**Category:** Help\
**Created:** [July 30, 2020, 8:34pm UTC](https://forum.makecode.com/t/i-cant-pass-a-lambda-to-on-button-event-in-python/2969 "2020-07-30T20:34:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [July 30, 2020, 8:34pm UTC](https://forum.makecode.com/t/i-cant-pass-a-lambda-to-on-button-event-in-python/2969/1 "2020-07-30T20:34:18Z")

</div>

Why can’t I pass a lambda to `controller.player1.on_button_event` for the function to run?

This doesn’t work:

```auto
controller.player1.on_button_event(ControllerButton.LEFT, ControllerButtonEvent.PRESSED, lambda: character.set_image(img("""
        . . . . . . . . . . . . . . . .
        . . . . f f f f f f . . . . . .
        . . . f 2 f e e e e f f . . . .
        . . f 2 2 2 f e e e e f f . . .
        . . f e e e e f f e e e f . . .
        . f e 2 2 2 2 e e f f f f . . .
        . f 2 e f f f f 2 2 2 e f . . .
        . f f f e e e f f f f f f f . .
        . f e e 4 4 f b e 4 4 e f f . .
        . . f e d d f 1 4 d 4 e e f . .
        . . . f d d d e e e e e f . . .
        . . . f e 4 e d d 4 f . . . . .
        . . . f 2 2 e d d e f . . . . .
        . . f f 5 5 f e e f f f . . . .
        . . f f f f f f f f f f . . . .
        . . . f f f . . . f f . . . . .
    """)))

```

Or this:

```auto
controller.player1.on_button_event(ControllerButton.LEFT, ControllerButtonEvent.PRESSED, lambda: console.log("hi"))

```

Or this:

```auto
game.on_update_interval(500, lambda: console.log("hi"))

```

All of them give me

```auto
Argument of type '{ TODO: any; }' is not assignable to parameter of type '() => void'.
Cannot find name 'Lambda'.

```

when I hover my mouse over the red squiggly lines.

Am I using `lambda` in-correctly because this version doesn’t support using `lambda` like this? This should be valid syntax in vanilla Python (3).

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [July 30, 2020, 10:50pm UTC](https://forum.makecode.com/t/i-cant-pass-a-lambda-to-on-button-event-in-python/2969/2 "2020-07-30T22:50:56Z")

</div>

Definitely looks like a bug! Would you mind filing this [on github](https://github.com/microsoft/pxt-arcade/issues)?

---

<div class="post-metadata">

**Author:** ![UnsignedArduino](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/unsignedarduino/32/592_2.png) [@UnsignedArduino](https://forum.makecode.com/u/UnsignedArduino)\
**Post date:** [July 30, 2020, 11:41pm UTC](https://forum.makecode.com/t/i-cant-pass-a-lambda-to-on-button-event-in-python/2969/3 "2020-07-30T23:41:51Z")

</div>

Sorry for the late reply, was eating dinner and contemplating how to word it, but I got it done!

> <https://github.com/microsoft/pxt-arcade/issues/2284>
>
> Describe the bug
> When using functions that require a function as an argument, (say, a callback function like game.on\_update\_interval) I often use...
