# How to get space bar to end routine only after rating is collected

**URL:** <https://discourse.psychopy.org/t/how-to-get-space-bar-to-end-routine-only-after-rating-is-collected/7486>\
**Category:** Builder\
**Tags:** code\
**Created:** [April 20, 2019, 5:25pm UTC](https://discourse.psychopy.org/t/how-to-get-space-bar-to-end-routine-only-after-rating-is-collected/7486 "2019-04-20T17:25:47Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![dvbridges](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/dvbridges/32/1918_2.png) [@dvbridges](https://discourse.psychopy.org/u/dvbridges)\
**Post date:** [April 24, 2019, 3:43pm UTC](https://discourse.psychopy.org/t/how-to-get-space-bar-to-end-routine-only-after-rating-is-collected/7486/8 "2019-04-24T15:43:16Z")

</div>

This was a problem with the slider rating equality check with ‘undefined’. Turns out getRating() returns an actual `undefined` type, rather than a string of ‘undefined’. So change:

`if (thisSlider.getRating() !== undefined) { // so equality check is with an undefined type, not string`

Here is a working example if that fails [sliderCode.psyexp](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/2X/f/f538da52a2c3f88c678cfb756f5b05ff646db890.psyexp) (6.2 KB)

---

_[View the full topic](https://discourse.psychopy.org/t/how-to-get-space-bar-to-end-routine-only-after-rating-is-collected/7486)._
