Skip to content

Top 6 Keyboards for Music Production 2026: Expert Picks

·19 min read·by

Welcome, fellow music creators! If you’re diving into the exciting world of digital audio workstations or looking to upgrade your setup, finding the best keyboards for music production is a crucial step. A good keyboard can unlock new creative possibilities, streamline your workflow, and ultimately enhance the quality of your tracks. Whether you’re a seasoned producer or just starting your musical journey, the right instrument makes all the difference. We’ve put together a list of top-performing keyboards designed to meet various needs and budgets, helping you make an informed choice for your home studio or portable rig.

Quick Product Comparison

.modern-product-table {
width: 100%;
border-collapse: separate;
border-spacing: 0;
background: white;
border-radius: 12px;
overflow: hidden;
box-shadow: 0 8px 32px rgba(0,0,0,0.1);
font-size: 14px;
}
.modern-product-table thead th {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 10px 8px;
text-align: left;
font-weight: 600;
font-size: 15px;
border: none;
}
.modern-product-table tbody td {
padding: 10px 8px;
border-bottom: 1px solid #f0f0f0;
vertical-align: middle;
}
.modern-product-table tbody tr:last-child td {
border-bottom: none;
}
.product-name {
font-weight: 600;
color: #2d3748;
font-size: 14px;
line-height: 1.4;
max-width: 300px;
}
.product-name a {
color: inherit;
text-decoration: none;
}
.product-name a:hover {
color: #ff6b35 !important;
}
.product-image-cell {
text-align: center;
width: 80px;
}
.product-image-cell img {
width: 60px;
height: 60px;
object-fit: cover;
border-radius: 8px;
border: 2px solid #e2e8f0;
transition: transform 0.2s ease;
}
.product-image-cell img:hover {
transform: scale(1.05);
}
.price-button-cell {
text-align: center;
width: 140px;
}
.price-button {
display: inline-block;
background: linear-gradient(135deg, #ff9900 0%, #ff6b35 100%);
color: white;
padding: 8px 12px;
text-decoration: none !important;
border-radius: 6px;
font-weight: 600;
font-size: 13px;
box-shadow: 0 2px 8px rgba(255,153,0,0.3);
transition: all 0.2s ease;
white-space: nowrap;
}
.price-button:hover {
transform: translateY(-1px);
box-shadow: 0 4px 12px rgba(255,153,0,0.4);
}
@media (max-width: 768px) {
.modern-product-table {
font-size: 13px;
}
.modern-product-table thead th {
padding: 8px 6px;
font-size: 14px;
}
.modern-product-table tbody td {
padding: 8px 6px;
}
.product-name {
font-size: 13px;
max-width: 200px;
}
.product-image-cell img {
width: 50px;
height: 50px;
}
.price-button {
padding: 6px 10px;
font-size: 12px;
}
}
@media (max-width: 480px) {
.modern-product-table {
font-size: 12px;
}
.modern-product-table thead th {
padding: 6px 4px;
font-size: 13px;
}
.modern-product-table tbody td {
padding: 6px 4px;
}
.product-name {
font-size: 12px;
max-width: 150px;
}
.product-image-cell {
width: 60px;
}
.product-image-cell img {
width: 40px;
height: 40px;
}
.price-button-cell {
width: 120px;
}
.price-button {
padding: 5px 8px;
font-size: 11px;
}
}

<!–

–>

<!–

–>

<!–

–>

<!–

–>

<!–

–>

<!–

–>

Product Image Check Price
1. RockJam 25 Key Bluetooth MIDI Keyboard, Excellent Choice for Portable Music Production… RockJam 25 Key Bluetooth MIDI Keyboard, Excellent Choice for Portable ⭐ N/A Check Price
2. Yamaha YPT-W320 76 Touch Sensitive Key Portable Keyboard for Beginners with Music Rest, Power Ada…… Yamaha YPT-W320 76 Touch Sensitive Key Portable Keyboard for Beginners ⭐ 4.7/5 Check Price
3. Casio Casiotone SA… Casio Casiotone SA ⭐ 4.5/5 Check Price
4. MUSTAR 61-Key Electric Piano Keyboard with Lighted Keys, Excellent for Music Production… MUSTAR 61-Key Electric Piano Keyboard with Lighted Keys, Excellent for ⭐ 4.5/5 Check Price
5. IMGZAR 61 Key Keyboard Piano for Beginners with Lighted Keys & Pro Teaching Modes,Includes Stand,…… IMGZAR 61 Key Keyboard Piano for Beginners with Lighted Keys & Pro Tea ⭐ 4.3/5 Check Price
6. Synido 25-Key USB MIDI Controller with 8 Drum Pads and OLED Screen for Music Production… Synido 25-Key USB MIDI Controller with 8 Drum Pads and OLED Screen for ⭐ 4.2/5 Check Price
h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

🏆 Best Choice

1. RockJam 25 Key Bluetooth MIDI Keyboard, Excellent Choice for Portable Music Production

RockJam 25 Key Bluetooth MIDI Keyboard, Excellent Choice for Portable Music Production

The RockJam 25 Key Bluetooth MIDI Keyboard is an excellent choice if you’re looking for a compact and portable solution for your music production needs. Its wireless capabilities and rechargeable battery make it incredibly convenient for creating music on the go. This keyboard offers a balance of playability and control, making it a strong contender among the best keyboards for music production, especially for mobile setups.

Key Features That Stand Out

  • ✓ Wireless Bluetooth MIDI connectivity for a clutter-free setup.
  • ✓ Built-in rechargeable battery supports portable music creation.
  • ✓ Features 8 backlit velocity-sensitive touch pads for dynamic playing.
  • ✓ Equipped with 8 360-degree control knobs for comprehensive parameter adjustments.
  • ✓ Compact and lightweight design, ideal for travel and small spaces.

Why We Recommend It

We recommend the RockJam 25 Key Bluetooth MIDI Keyboard for its exceptional portability and versatile control options. The wireless MIDI and internal battery mean you can literally create anywhere, which is a huge plus for spontaneous inspiration. It’s perfect for sketching out ideas or controlling your DAW without being tethered by cables, a truly modern approach to music production.

Best For

This keyboard is best for producers and musicians who prioritize portability and wireless connectivity. It’s ideal for those with limited studio space or anyone who needs a reliable MIDI controller for travel or on-the-go creative sessions.

Pros and Cons

Pros:
  • Excellent portability with Bluetooth MIDI and rechargeable battery.
  • Versatile controls with pads and knobs for expressive performance.
  • Easy to integrate into any DAW setup wirelessly.
  • Compact size fits easily into backpacks and small studio spaces.
Cons:
  • Only 25 keys, which might be limiting for advanced piano players.
  • Keys are mini-sized, not full-sized, which can take some getting used to.
  • No built-in sounds, purely a MIDI controller.

Customer Reviews

Customer Review: Very adequate for learning basic piano skills and music the ranges close to middle range. Durable, light weight and good key quality.

Customer Review: I see a lot of reviews for using this device for kids as a beginner piano. This is a great product, but you have to understand what it is before buying it. If you want to buy a device for you or your kid to learn how to play piano, this isn’t what you want. You’ll probably want a full size keyboard

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

⭐ Editor’s Choice

2. Yamaha YPT-W320 76 Touch Sensitive Key Portable Keyboard for Beginners with Music Rest, Power Ada…

Yamaha YPT-W320 76 Touch Sensitive Key Portable Keyboard for Beginners

For those taking their first serious steps into playing and producing music, the Yamaha YPT-W320 offers a fantastic blend of features. With 76 touch-sensitive keys, it provides a more authentic piano feel than smaller MIDI controllers, which is ideal for developing proper playing technique. This model stands out as one of the best keyboards for music production for beginners who also want a strong learning platform.

Key Features That Stand Out

  • ✓ 76 full-size touch-sensitive keys for expressive dynamic control.
  • ✓ “Keys to Success” learning system guides users step-by-step.
  • ✓ “Touch Tutor” feature helps develop dynamic playing based on key touch.
  • ✓ Includes a music rest and power adapter, ready for practice.
  • ✓ Yamaha’s renowned sound quality and reliability.

Why We Recommend It

The Yamaha YPT-W320 is a superb choice for beginners who want a versatile keyboard that also functions well for basic music production. Its touch-sensitive keys are critical for developing expressive playing, and the built-in learning tools are incredibly helpful. It’s a comprehensive package that lets you play, learn, and dabble in production, making it a great entry point into the world of music creation.

Best For

This keyboard is best for aspiring pianists and beginner music producers who want a full-sized, touch-sensitive keyboard for both learning and basic production tasks. It’s also great for families where multiple members might be learning to play.

Pros and Cons

Pros:
  • 76 touch-sensitive keys provide a realistic piano feel.
  • Excellent learning tools for beginners to develop playing skills.
  • Good sound quality for an entry-level portable keyboard.
  • Versatile for both practice and connecting to a DAW for production.
Cons:
  • Larger footprint than 25 or 49-key MIDI controllers.
  • Focus is more on performance and learning than advanced DAW control.
  • Still a portable keyboard, not a fully weighted digital piano.

Customer Reviews

Customer Review: My oldest son started taking piano classes as an elective at school this year, and he has been absolutely loving it. Since the beginning of the school year, I’d been wanting to get him a keyboard so he could practice at home, and I’m really glad I chose this one.The sound quality is great, the keys

Customer Review: REALLY great product and sound! For not being the most expensive version, this one really delivers on quality. Sounds great, lots of things to try. Very glad we bought this keyboard!!

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

💰 Best Budget

3. Casio Casiotone SA

Casio Casiotone SA

The Casio Casiotone SA is a fantastic entry-level keyboard, particularly for young aspiring musicians or anyone looking for an ultra-portable and affordable option. While not a professional MIDI controller, it introduces basic keyboard playing and sound exploration in a fun, accessible package. It’s a great starting point for budding talents who might eventually transition to more advanced keyboards for music production.

Key Features That Stand Out

  • ✓ 32 mini keys, perfect for small hands and compact spaces.
  • ✓ Features 100 built-in tones, offering a variety of instrument sounds.
  • ✓ One-touch tone selection for instant access to piano, trumpet, or drum set.
  • ✓ Extremely lightweight and portable for easy transport.
  • ✓ Simple and intuitive interface, ideal for beginners.

Why We Recommend It

We recommend the Casio Casiotone SA as an excellent budget-friendly option, especially for young children or adults who want a very basic, portable keyboard for casual play or initial exploration. It’s not designed for serious production, but it’s a wonderful tool for sparking interest in music and for quick, simple melodic input in a pinch.

Best For

This keyboard is best for young beginners (under 5) to learn basic keyboard skills, or for anyone needing a highly portable and inexpensive toy keyboard for casual fun and simple melody input.

Pros and Cons

Pros:
  • Very affordable, making it accessible for any budget.
  • Compact size and lightweight design for ultimate portability.
  • A wide variety of built-in tones for exploration and fun.
  • Durable and robust, suitable for children’s use.
Cons:
  • Mini keys are not ideal for developing professional piano technique.
  • Limited functionality for serious music production compared to MIDI controllers.
  • Not touch-sensitive, lacking expressive control.

Customer Reviews

Customer Review: Simple, small, fun. Just what I was looking for. Every now and then I’ll hear a riff I just have to learn. Latest is pete rodriquez i like it like that.Has octave jump/drop buttons easy to hit when playing boosting its range.Built in speakers sound good with decent volume for what this is.Simple op

Customer Review: For a keyboard aimed at young children this is a good one. Solidly well built by a reputable keyboard maker Casio. The sound quality is good for the piano. Does a lot of things so it would take a kid a while to learn this. The keys are smaller than a regular keyboard of course so it’s a good way to

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

4. MUSTAR 61-Key Electric Piano Keyboard with Lighted Keys, Excellent for Music Production

MUSTAR 61-Key Electric Piano Keyboard with Lighted Keys, Excellent for Music Production

The MUSTAR 61-Key Electric Piano Keyboard is designed with beginners in mind, particularly those who benefit from visual learning cues. Its lighted keys make learning melodies and chords engaging and straightforward, helping new players build confidence quickly. This keyboard is a great option for individuals looking for keyboards for music production that combine learning features with standard piano functionality.

Key Features That Stand Out

  • ✓ Lighted keys function provides visual guidance for learning songs.
  • ✓ Offers 3 intelligent teaching modes: One Key, Follow, and Ensemble.
  • ✓ Audio input function allows playback of external music through the keyboard.
  • ✓ Features a rich selection of built-in music and instrument tones.
  • ✓ 61 full-sized keys provide ample range for playing various pieces.

Why We Recommend It

We recommend the MUSTAR 61-Key Electric Piano Keyboard for its innovative lighted key system, which makes learning music incredibly accessible and fun. For beginners who might feel overwhelmed by traditional learning methods, this feature is a game-changer. It’s a solid, feature-rich keyboard that can serve both as a learning instrument and a basic tool for music production.

Best For

This keyboard is best for absolute beginners, especially children and adults who prefer visual learning methods. It’s also suitable for those seeking a multi-functional keyboard for both practice and entry-level music creation.

Pros and Cons

Pros:
  • Lighted keys greatly assist in learning and practicing.
  • Multiple teaching modes cater to different learning styles.
  • Good sound quality and a wide array of tones for exploration.
  • Includes audio input for playing along with your favorite tracks.
Cons:
  • Keys may not be touch-sensitive, limiting expressive dynamics.
  • More focused on learning and playing than advanced DAW control.
  • Physical size might be large for very small spaces.

Customer Reviews

Customer Review: Works well and the description is accurate. Lots of different functions. Happy with how loud the volume goes as well. Surprisingly low price for how good the quality is. Definitely recommend.

Customer Review: My 5 year old got this for Christmas and loves it! The headphones are perfect for keeping noise level down. Very sturdy and good for beginners!

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

5. IMGZAR 61 Key Keyboard Piano for Beginners with Lighted Keys & Pro Teaching Modes,Includes Stand,…

IMGZAR 61 Key Keyboard Piano for Beginners with Lighted Keys & Pro Teaching Modes,Includes Stand,

The IMGZAR 61 Key Keyboard Piano is another excellent option for beginners, offering a comprehensive package for learning and playing. With lighted keys and professional teaching modes, it provides a supportive environment for new musicians. This keyboard also comes with a stand, headphones, and a stool, making it an all-in-one solution for anyone looking to get started with keyboards for music production or piano learning.

Key Features That Stand Out

  • ✓ Multifunctional 61-key piano keyboard with diverse sound modes.
  • ✓ Lighted keys and professional teaching modes for guided learning.
  • ✓ Includes a liftable Z-shaped piano keyboard frame for comfortable playing.
  • ✓ Equipped with a professional noise reduction chip and dual-speaker stereo for high-quality sound.
  • ✓ Comes with headphones and a stool for a complete beginner setup.

Why We Recommend It

We recommend the IMGZAR 61 Key Keyboard Piano because it’s a complete starter kit. The inclusion of a stand, headphones, and stool means you’re ready to play right out of the box, which is incredibly convenient for new users. Its focus on teaching modes combined with good sound quality makes it a valuable asset for learning and basic musical experimentation.

Best For

This keyboard is best for beginners who want a complete package with essential accessories included. It’s ideal for students and hobbyists who are serious about learning the piano and exploring simple music production.

Pros and Cons

Pros:
  • All-inclusive package with stand, headphones, and stool.
  • Lighted keys and various teaching modes facilitate learning.
  • Good sound quality with professional noise reduction technology.
  • Sturdy and adjustable Z-shaped stand for ergonomic playing.
Cons:
  • Keys might not be fully weighted or touch-sensitive for advanced players.
  • The teaching features might overshadow advanced MIDI production capabilities.
  • Assembly required for the stand.

Customer Reviews

Customer Review: First, it is a really nice keyboard. It is super comfortable. It comes with really nice headphones to use while playing, and it also has a stand, so you can either sit with your keyboard on top of the table, or you can put the keyboard on a stand if you have a chair to put in front of it, and it is

Customer Review: First, it is a really nice keyboard. It is super comfortable. It comes with really nice headphones to use while playing, and it also has a stand, so you can either sit with your keyboard on top of the table, or you can put the keyboard on a stand if you have a chair to put in front of it, and it is

h3 { transition: color 0.2s ease; } h3:hover { color: #ff6b35; }

6. Synido 25-Key USB MIDI Controller with 8 Drum Pads and OLED Screen for Music Production

Synido 25-Key USB MIDI Controller with 8 Drum Pads and OLED Screen for Music Production

The Synido 25-Key USB MIDI Controller is a sleek and robust tool specifically designed for modern music producers. Its compact size, combined with a striking aesthetic and comprehensive control features, makes it a valuable addition to any studio, big or small. This controller is built for those who prioritize efficient workflow and creative versatility, solidifying its place among the best keyboards for music production.

Key Features That Stand Out

  • ✓ Bold semi-transparent high-gloss finish made from high-strength PC+ material.
  • ✓ Built-in arpeggiator with adjustable tempo for instant melodic inspiration.
  • ✓ Fast workflow with onboard OLED screen for direct editing of MIDI parameters (Note, CC, PC, Channel).
  • ✓ Features 8 velocity-sensitive drum pads for expressive beat-making.
  • ✓ 25 velocity-sensitive keys for dynamic melodic and harmonic input.

Why We Recommend It

We recommend the Synido 25-Key USB MIDI Controller for its robust build, intelligent design, and powerful features packed into a small footprint. The built-in arpeggiator and immediate onboard editing capabilities are fantastic for keeping creative momentum going. It’s an ideal MIDI controller for producers who need quick access to sound manipulation and beat creation within their DAW.

Best For

This controller is best for electronic music producers, beatmakers, and anyone needing a compact yet powerful MIDI controller for their DAW. It’s particularly useful for live performance or studio work where space is at a premium.

Pros and Cons

Pros:
  • Durable and stylish design with a high-quality build.
  • Excellent built-in arpeggiator for creative melody generation.
  • Onboard OLED screen provides quick and intuitive parameter editing.
  • Combines keys and drum pads for versatile input.
Cons:
  • Only 25 keys, which can be limiting for complex piano arrangements.
  • Requires a computer/DAW to generate sound, as it’s a controller only.
  • Might require some learning curve for beginners unfamiliar with MIDI mapping.

Customer Reviews

Customer Review: This thing is great for a novice (like me).Works great but I am not savvy enough to work it completely. Right now I’m just “playing with it”, but I’m having a ball.

Customer Review: This thing is great for a novice (like me).Works great but I am not savvy enough to work it completely. Right now I’m just “playing with it”, but I’m having a ball.

Complete Buying Guide for Best Keyboards For Music Production

Choosing the best keyboard for music production can feel a bit overwhelming, given the vast array of options out there. It’s not just about hitting notes; it’s about controlling your digital instruments, shaping sounds, and integrating seamlessly with your software. Let’s break down the essential factors to consider so you can find the perfect fit for your creative space.

Essential Factors We Consider

When we evaluate keyboards for music production, we look at several key areas. First, the key type and count are vital. Do you need fully weighted, semi-weighted, or synth-action keys? How many keys – 25, 49, 61, or 88 – will best suit your playing style and available space? For piano-heavy tracks, 88 weighted keys are ideal, while compact MIDI controllers with 25 keys are perfect for travel or beat-making. Another crucial factor is connectivity. Most modern keyboards offer USB-MIDI, but some also feature traditional 5-pin MIDI DIN ports, Bluetooth, or even audio interfaces built-in. Consider what connections you’ll need for your setup. Finally, the inclusion of control features like drum pads, faders, knobs, and assignable buttons can significantly enhance your workflow, allowing you to manipulate your DAW and virtual instruments without constantly reaching for your mouse.

Budget Planning

Your budget plays a significant role in your choice of music production keyboard. Entry-level MIDI controllers and digital pianos can start from under $100, offering basic functionality for beginners. These are great for getting started, but often lack advanced controls or premium keybeds. Mid-range options, typically from $200-$500, provide a substantial leap in build quality, key feel, and control features. You’ll find more durable chassis, better velocity-sensitive keys, and a wider array of pads and knobs in this price bracket, which is perfect for intermediate producers. High-end professional keyboards and master controllers can cost upwards of $500, offering fully weighted hammer-action keys, deep DAW integration, and extensive customization. Remember, investing in a quality keyboard is an investment in your musical journey, so consider what features are truly essential for your current and future needs.

Final Thoughts

Ultimately, the best keyboard for music production is the one that fits your personal workflow, budget, and creative aspirations. Don’t rush your decision. Think about what kind of music you’ll be making, how much space you have, and what features will truly inspire you. Whether it’s a compact MIDI controller for portable beat-making or a full-sized digital piano for expressive compositions, there’s a perfect keyboard out there waiting for you. Take your time, read reviews, and perhaps even try a few out if possible, to get a feel for what works best in your hands.

Frequently Asked Questions

Q: What is the main difference between a MIDI keyboard controller and a digital piano for music production?

A: A MIDI keyboard controller is primarily designed to send MIDI data to a computer or other MIDI-compatible devices. It doesn’t typically produce sound on its own but is used to control virtual instruments and software in your Digital Audio Workstation (DAW). A digital piano, on the other hand, usually has built-in sounds and speakers, allowing it to function as a standalone instrument. While many digital pianos also have MIDI output, their main focus is on replicating the feel and sound of an acoustic piano, often with weighted keys.

Q: Do I need a keyboard with weighted keys for music production?

A: It depends on your primary use. If you’re mainly playing piano-heavy parts or are an experienced pianist, weighted keys provide a more realistic and expressive playing experience. However, for electronic music, synthesizers, drum programming, or if you prefer a lighter touch, a keyboard with semi-weighted or synth-action keys might be more suitable. MIDI controllers often feature lighter keys, which can be faster for certain styles of playing.

Q: How many keys should my music production keyboard have?

A: The ideal number of keys varies greatly. A 25-key controller is extremely portable and great for basic melody lines, basslines, and drum programming. A 49 or 61-key keyboard offers a good balance, providing enough range for two-handed playing without taking up too much space. For serious pianists or composers who need access to a full range of octaves, an 88-key keyboard (often fully weighted) is the best choice.

Q: Can I use any keyboard with my DAW (Digital Audio Workstation)?

A: Most modern keyboards with USB-MIDI connectivity can be easily connected to a computer and used with any DAW like Ableton Live, Logic Pro, FL Studio, or Pro Tools. Your DAW will recognize the keyboard as a MIDI input device, allowing you to play and record virtual instruments. Some keyboards also offer deeper integration with specific DAWs, providing dedicated transport controls or automatic mapping of parameters.

Q: What are drum pads and why are they useful for music production?

A: Drum pads are usually velocity-sensitive rubber pads on a keyboard or controller that are excellent for finger drumming, triggering samples, or launching clips in your DAW. They offer a tactile and intuitive way to create beats and rhythms, making your music production process more engaging and hands-on than simply clicking notes with a mouse.

There you have it – our comprehensive guide to finding the best keyboards for music production! We hope this rundown has helped you narrow down your choices and feel more confident in your next gear purchase. Remember, the perfect keyboard is the one that inspires you to create and helps bring your musical ideas to life. Don’t hesitate to click on the “Check Price on Amazon” buttons for any of the products that caught your eye to explore current deals and detailed specifications. Happy producing!

// Fetch real-time product data for all products when page loads
(function() {
const products = [‘B0BTPPYY8J’, ‘B0D4R6DYW1’, ‘B00I0ROV00’, ‘B09BTDGCX3’, ‘B0C3388JTY’, ‘B0CNSZZ84W’];
const affiliateTag = ‘shoukhintech01-20’;

async function fetchLiveProductData(asin) {
try {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘⏳ Fetching…’;

const amazonUrl = ‘https://www.amazon.com/dp/’ + asin;
const response = await fetch(‘https://api.allorigins.win/raw?url=’ + encodeURIComponent(amazonUrl));
const html = await response.text();
const parser = new DOMParser();
const doc = parser.parseFromString(html, ‘text/html’);

let price = null;
const priceWhole = doc.querySelector(‘.a-price-whole’);
const priceFraction = doc.querySelector(‘.a-price-fraction’);
if (priceWhole) {
price = ‘$’ + priceWhole.textContent.trim() + (priceFraction ? priceFraction.textContent.trim() : ”);
}

let rating = null;
const ratingEl = doc.querySelector(‘[data-hook=”average-star-rating”] .a-icon-alt’);
if (ratingEl) {
const match = ratingEl.textContent.match(/(\d+\.\d+)/);
if (match) rating = match[1];
}

let reviewCount = null;
const reviewEl = doc.querySelector(‘#acrCustomerReviewText’);
if (reviewEl) reviewCount = reviewEl.textContent.trim();

if (price) {
const priceEl = document.getElementById(‘price-‘ + asin);
if (priceEl) {
priceEl.innerHTML = price;
priceEl.style.animation = ‘pulse 0.5s’;
}
}

// if (rating) {
// const ratingEl = document.getElementById(‘rating-‘ + asin);
// if (ratingEl) {
// const stars = ‘⭐’.repeat(Math.floor(parseFloat(rating)));
// ratingEl.innerHTML = stars + ‘ ‘ + rating + ‘/5’;
// ratingEl.style.animation = ‘pulse 0.5s’;
// }
// }

if (reviewCount) {
const reviewsEl = document.getElementById(‘reviews-‘ + asin);
if (reviewsEl) {
reviewsEl.innerHTML = reviewCount;
reviewsEl.style.animation = ‘pulse 0.5s’;
}
}

if (updateTimeEl) {
const now = new Date();
const timeStr = now.toLocaleString(‘en-US’, {
month: ‘long’, day: ‘numeric’, year: ‘numeric’,
hour: ‘numeric’, minute: ‘2-digit’, hour12: true
});
updateTimeEl.innerHTML = ‘✓ Updated: ‘ + timeStr;
}
} catch (error) {
const updateTimeEl = document.getElementById(‘update-time-‘ + asin);
if (updateTimeEl) updateTimeEl.innerHTML = ‘✓ Cached data’;
}
}

const style = document.createElement(‘style’);
style.textContent = `@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }`;
document.head.appendChild(style);

function loadAllProducts() {
products.forEach((asin, index) => {
setTimeout(() => fetchLiveProductData(asin), index * 2000);
});
}

if (document.readyState === ‘loading’) {
document.addEventListener(‘DOMContentLoaded’, loadAllProducts);
} else {
loadAllProducts();
}
})();

Share.

Similar Posts

Leave a comment

Share