title: Bootstrap: Carousel with keyboard controls
body: <p>Has anyone been able to implement Twitter Bootstrap carousel with keyboard controls? I know this is going to be implement in the next release, but for now I was wondering if any of you has been able to make it work.</p>
  
  <p>Here's my current code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
    jQuery(document).keypress(function(event) {
  
    if (event.keyCode === RIGHT_ARROW) {
    $('a.carousel-control.right').trigger('click');
  
    }
  
    if (event.keyCode === LEFT_ARROW) {
  
    $('a.carousel-control.left').trigger('click');
  
    }
  
    });
  
  &lt;/script&gt;
  </code></pre>
  
  <p>But I'm not getting anywhere with this. Any ideas?</p>
  
  <p>Edit: Here's the Wordpress code I am running...</p>
  
  <pre><code>                        &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;
  
                          &lt;article id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class('clearfix'); ?&gt; role="article" itemscope itemtype="http://schema.org/BlogPosting"&gt;
  
  
                              &lt;?php if ( $post-&gt;post_type == 'portfolios' &amp;&amp; $post-&gt;post_status == 'publish' ) {
                              $attachments = get_posts( array(
  
                              'post_type' =&gt; 'attachment',
                              'posts_per_page' =&gt; -1,
                              'post_parent' =&gt; $post-&gt;ID,
                              'exclude' =&gt; get_post_thumbnail_id(),
                              'orderby' =&gt; 'menu_order',
                              'order' =&gt; 'ASC'    
                                  ) );
  
                              ?&gt;
  
                              &lt;?php if ( $attachments ) {  
                              $the_rest = array_slice($attachments, 0, 100);
                              ?&gt;      
  
                              &lt;div id="carousel-&lt;?php the_ID(); ?&gt;" class="featured-carousel carousel slide carousel-fade"&gt;
  
                                  &lt;div class="carousel-inner"&gt;
  
                                      &lt;?php 
                                      global $post;
                                      $post_num = 0;  
                                      foreach( $the_rest as $attachment) :
                                      $image = wp_get_attachment_image_src( $attachment-&gt;ID, 'orion-thumb-900', false );
                                      $post_num++;
                                      ?&gt;          
  
                                      &lt;div class="item &lt;?php if($post_num == 1){ echo 'active'; } ?&gt;"&gt;
                                      &lt;?php echo "&lt;img src='" . $image[0] . "'&gt;"; ?&gt;  
                                        &lt;div class="container"&gt;
                                        &lt;/div&gt; &lt;!-- /.container --&gt;
                                      &lt;/div&gt; &lt;!-- /.item --&gt;
  
                                      &lt;?php endforeach; ?&gt;          
  
                                      &lt;?php } ?&gt;
  
                                      &lt;?php } ?&gt;      
  
                                  &lt;/div&gt; &lt;!-- /.carousel-inner --&gt;
  
                                      &lt;a class="left carousel-control" href="#carousel-&lt;?php the_ID(); ?&gt;" data-slide="prev"&gt;&amp;lsaquo;&lt;/a&gt;
                                      &lt;a class="right carousel-control" href="#carousel-&lt;?php the_ID(); ?&gt;" data-slide="next"&gt;&amp;rsaquo;&lt;/a&gt;
  
                              &lt;/div&gt; &lt;!-- /.carousel --&gt;
  
                                  &lt;section class="entry-content clearfix"&gt;
  
                                      &lt;?php the_content(); ?&gt;
  
                                      &lt;?php orion_related_posts(); ?&gt;
  
                                  &lt;/section&gt; &lt;!-- end article section --&gt;
  
                          &lt;/article&gt; &lt;!-- end article --&gt;
  
                      &lt;?php endwhile; ?&gt;  
  </code></pre>